<commit_before>/**
 * @license
 * resol-vbus - A JavaScript library for processing RESOL VBus data
 */
'use strict';

module.exports = function(grunt) {
    // configure tasks
    grunt.initConfig({
        jshint: {
            options: {
                jshintrc: '.jshintrc',
            },
            all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
        },
        'mocha-chai-sinon': {
            build: {
                src: ['./test/specs/**/*.spec.js'],
                options: {
                    ui: 'bdd',
                    reporter: 'spec'
                }
            },
            xcoverage: {
                src: ['./test/specs/**/*.spec.js'],
                options: {
                    ui: 'bdd',
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: './coverage.html',
                    'data-cover-flags': {
                        debug: true
                    }
                }
            }
        },
        copy: {
            logger: {
                files: [ {
                    expand: true,
                    cwd: 'nw-apps/logger',
                    src: [
                        '**/*',
                    ],
                    dest: 'nw-builds/tmp/logger'
                }, {
                    expand: true,
                    cwd: '.',
                    src: [
                        'package.json',
                        'src/**/*',
                    ],
                    dest: 'nw-builds/tmp/logger/node_modules/resol-vbus'
                } ]
            }
        },
        shell: {
            logger: {
                command: '(cd nw-builds/tmp/logger/; npm install --production; bower install; cd node_modules/resol-vbus; npm install --production)'
            }
        },
        nodewebkit: {
            options: {
                version: '0.8.2',
                build_dir: './nw-builds',
                mac: true,
                win: false,
                linux32: false,
                linux64: false
            },
            logger: {
                options: {
                    app_name: 'RESOL VBus Logger'
                },
                src: [
                    'nw-builds/tmp/logger/**/*',
                ]
            }
        },
        open: {
            logger: {
                path: 'nw-builds/releases/RESOL VBus Logger/mac/RESOL VBus Logger.app',
            },
        },
        compress: {
            logger: {
                options: {
                    archive: 'nw-builds/releases/RESOL VBus Logger/mac/RESOL VBus Logger.zip'
                },
                files: [ {
                    expand: true,
                    cwd: 'nw-builds/releases/RESOL VBus Logger/mac',
                    src: [ 'RESOL VBus Logger.app/**/*' ],
                } ]
            }
        }
    });

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

    // register tasks for execution chain
    grunt.registerTask('test', [
        'mocha-chai-sinon:build'
    ]);
    grunt.registerTask('coverage', [
        'mocha-chai-sinon:coverage'
    ]);

    grunt.registerTask('deploy:logger', [
        'copy:logger',
        'shell:logger',
        'nodewebkit:logger',
        'open:logger',
        'compress:logger',
    ]);
};
<commit_msg>- Excluded auto-generated VBus specification data from JSHint task<commit_after>/**
 * @license
 * resol-vbus - A JavaScript library for processing RESOL VBus data
 */
'use strict';

module.exports = function(grunt) {
    // configure tasks
    grunt.initConfig({
        jshint: {
            options: {
                jshintrc: '.jshintrc',
            },
            all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!src/specification-data.js']
        },
        'mocha-chai-sinon': {
            build: {
                src: ['./test/specs/**/*.spec.js'],
                options: {
                    ui: 'bdd',
                    reporter: 'spec'
                }
            },
            xcoverage: {
                src: ['./test/specs/**/*.spec.js'],
                options: {
                    ui: 'bdd',
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: './coverage.html',
                    'data-cover-flags': {
                        debug: true
                    }
                }
            }
        },
        copy: {
            logger: {
                files: [ {
                    expand: true,
                    cwd: 'nw-apps/logger',
                    src: [
                        '**/*',
                    ],
                    dest: 'nw-builds/tmp/logger'
                }, {
                    expand: true,
                    cwd: '.',
                    src: [
                        'package.json',
                        'src/**/*',
                    ],
                    dest: 'nw-builds/tmp/logger/node_modules/resol-vbus'
                } ]
            }
        },
        shell: {
            logger: {
                command: '(cd nw-builds/tmp/logger/; npm install --production; bower install; cd node_modules/resol-vbus; npm install --production)'
            }
        },
        nodewebkit: {
            options: {
                version: '0.8.2',
                build_dir: './nw-builds',
                mac: true,
                win: false,
                linux32: false,
                linux64: false
            },
            logger: {
                options: {
                    app_name: 'RESOL VBus Logger'
                },
                src: [
                    'nw-builds/tmp/logger/**/*',
                ]
            }
        },
        open: {
            logger: {
                path: 'nw-builds/releases/RESOL VBus Logger/mac/RESOL VBus Logger.app',
            },
        },
        compress: {
            logger: {
                options: {
                    archive: 'nw-builds/releases/RESOL VBus Logger/mac/RESOL VBus Logger.zip'
                },
                files: [ {
                    expand: true,
                    cwd: 'nw-builds/releases/RESOL VBus Logger/mac',
                    src: [ 'RESOL VBus Logger.app/**/*' ],
                } ]
            }
        }
    });

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

    // register tasks for execution chain
    grunt.registerTask('test', [
        'mocha-chai-sinon:build'
    ]);
    grunt.registerTask('coverage', [
        'mocha-chai-sinon:coverage'
    ]);

    grunt.registerTask('deploy:logger', [
        'copy:logger',
        'shell:logger',
        'nodewebkit:logger',
        'open:logger',
        'compress:logger',
    ]);
};
<|endoftext|>


<commit_before>/*jshint camelcase:false */
/**
 * crude
 *
 */

module.exports = function( grunt ) {

  var pkg = grunt.file.readJSON('package.json');

  grunt.loadNpmTasks('grunt-release');

  //
  // Grunt configuration:
  //
  //
  grunt.initConfig({
    // Project configuration
    // ---------------------
    //

    pkg: pkg,

    release: {
      options: {
        bump: true, //default: true
        file: 'package.json', //default: package.json
        add: true, //default: true
        commit: true, //default: true
        tag: true, //default: true
        push: true, //default: true
        pushTags: true, //default: true
        npm: true, //default: true
        tagName: 'v<%= version %>', //default: '<%= version %>'
        commitMessage: 'releasing v<%= version %>', //default: 'release <%= version %>'
        tagMessage: 'v<%= version %>' //default: 'Version <%= version %>'
      }
    },
  });
};
<commit_msg>add jshint task<commit_after>/*jshint camelcase:false */
/**
 * crude
 *
 */

module.exports = function( grunt ) {
  var pkg = grunt.file.readJSON('package.json');

  grunt.loadNpmTasks('grunt-release');

  //
  // Grunt configuration:
  //
  //
  grunt.initConfig({
    // Project configuration
    // ---------------------
    //

    pkg: pkg,

    jshint: {
      options: {
        jshintrc: true,
      },
      lib: ['lib/**/*.js'],
    },

    release: {
      options: {
        bump: true, //default: true
        file: 'package.json', //default: package.json
        add: true, //default: true
        commit: true, //default: true
        tag: true, //default: true
        push: true, //default: true
        pushTags: true, //default: true
        npm: true, //default: true
        tagName: 'v<%= version %>', //default: '<%= version %>'
        commitMessage: 'releasing v<%= version %>', //default: 'release <%= version %>'
        tagMessage: 'v<%= version %>' //default: 'Version <%= version %>'
      }
    },
  });
};
<|endoftext|>


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

    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        build: {
            path: "build/<%= pkg.version %>",
            vendor: "<%= build.path %>/vendor"
        },
        clean: {
            dist: ["<%= build.path %>/*"]
        },
        jshint: {
            files: ["Gruntfile.js", "src/**/*.js"],
            options: {
                globals: {
                    jQuery: true
                }
            }
        },
        concat: {
            options: {
                sourceMap: true
            },
            vendors: {
                src: [
                    "./bower_components/webcomponentsjs/webcomponents-lite.js",
                    "./bower_components/jquery/dist/jquery.js",
                    "./bower_components/bootstrap/dist/js/bootstrap.js",
                    "./bower_components/bootstrap-table/dist/bootstrap-table.js",
                    "./bower_components/bootstrap-treeview/dist/bootstrap-treeview.js",
                    "./bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js",
                    "./bower_components/underscore/underscore.js",
                    "./bower_components/backbone/backbone.js",
                    "./bower_components/highcharts-release/highcharts.js",
                    "./bower_components/qtip2/jquery.qtip.js",
                    "./bower_components/uri.js/src/URI.js",
                    "./bower_components/cookies-js/dist/cookies.js",
                    "./bower_components/moment/moment.js",
                    "./bower_components/crypto-js/crypto-js.js"
                ],
                dest: "<%= build.path %>/vendors.js"
            },
            jsorolla: {
                src: [
                    "./lib/jsorolla/src/lib/clients/rest-client.js",
                    "./lib/jsorolla/src/lib/clients/cellbase-client-config.js",
                    "./lib//jsorolla/src/lib/clients/cellbase-client.js",
                    "./lib/jsorolla/src/lib/clients/opencga-client-config.js",
                    "./lib/jsorolla/src/lib/clients/opencga-client.js",
                    "./lib/jsorolla/src/lib/cache/indexeddb-cache.js",
                    "./lib/jsorolla/src/lib/utils.js",
                    "./lib/jsorolla/src/lib/svg.js",
                    "./lib/jsorolla/src/lib/visualisation/lollipop.js",
                    "./lib/jsorolla/src/lib/opencga/variant/variant-utils.js"
                ],
                dest: "<%= build.path %>/jsorolla-clients.js"
            },
            genomeViewer: {
                src: [
                    "./lib/jsorolla/build/2.0.0-beta/genome-viewer/gv-config.js",
                    "./lib/jsorolla/build/2.0.0-beta/genome-viewer/genome-viewer.js"
                ],
                dest: "<%= build.path %>/genome-viewer.js"
            }
        },
        uglify: {
            options: {
                banner: "/*! IVA <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n"
            },
            dist: {
                files: {
                    "<%= build.path %>/vendors.min.js": ["<%= build.path %>/vendors.js"],
                    // '<%= build.path %>/jsorolla.min.js': ['<%= build.path %>/jsorolla-clients.js']
                }
            }
        },
        copy: {
            dist: {
                files: [
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap/dist/css/bootstrap.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-table/dist/bootstrap-table.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-treeview/dist/bootstrap-treeview.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/css/font-awesome.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["qtip2/jquery.qtip.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/fonts/*"], dest: "<%= build.path %>/fonts" },
                    {   flatten: true, expand: true, cwd: "./lib", src: ["jsorolla/styles/css/style.css"], dest: "<%= build.path %>/css" },
                    {   expand: true, cwd: "./bower_components", src: ["polymer/*"], dest: "<%= build.vendor %>" },
                    {   expand: true, cwd: "src", src: ["index.html"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["config.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "./", src: ["LICENSE"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["images/*"], dest: "<%= build.path %>/" }
                ]
            }
        },
        processhtml: {
            options: {
                strip: true
            },
            dist: {
                files: {
                    "<%= build.path %>/index.html": ["src/index.html"]
                }
            }
        },
        vulcanize: {
            default: {
                options: {
                    // Task-specific options go here.
                    stripComments: true,
                    excludes: ["bower_components/polymer/polymer.html"]
                },
                files: {
                    "<%= build.path %>/iva-app.html": "src/iva-app.html"
                }
            }
        },
        watch: {
            files: ["<%= jshint.files %>"],
            tasks: ["jshint"]
        },
        replace: {
            dist: {
                options: {
                    patterns: [
                        {
                            match: /\.\.\/bower_components/g,
                            replacement: "vendor"
                        }
                    ]
                },
                files: [
                    {expand: true, flatten: true, src: ["<%= build.path %>/index.html"], dest: "<%= build.path %>"},
                    {expand: true, flatten: true, src: ["<%= build.path %>/iva-app.html"], dest: "<%= build.path %>"},

                ]
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-processhtml");
    grunt.loadNpmTasks("grunt-vulcanize");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-replace");

    grunt.registerTask("default", ["clean", "jshint", "copy", "concat", "uglify", "processhtml", "vulcanize", "replace"]);
    grunt.registerTask("cl", ["clean"]);
};<commit_msg>Add number of genes to Panels and make grunt to copy panels.js to build<commit_after>
module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        build: {
            path: "build/<%= pkg.version %>",
            vendor: "<%= build.path %>/vendor"
        },
        clean: {
            dist: ["<%= build.path %>/*"]
        },
        jshint: {
            files: ["Gruntfile.js", "src/**/*.js"],
            options: {
                globals: {
                    jQuery: true
                }
            }
        },
        concat: {
            options: {
                sourceMap: true
            },
            vendors: {
                src: [
                    "./bower_components/webcomponentsjs/webcomponents-lite.js",
                    "./bower_components/jquery/dist/jquery.js",
                    "./bower_components/bootstrap/dist/js/bootstrap.js",
                    "./bower_components/bootstrap-table/dist/bootstrap-table.js",
                    "./bower_components/bootstrap-treeview/dist/bootstrap-treeview.js",
                    "./bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js",
                    "./bower_components/underscore/underscore.js",
                    "./bower_components/backbone/backbone.js",
                    "./bower_components/highcharts-release/highcharts.js",
                    "./bower_components/qtip2/jquery.qtip.js",
                    "./bower_components/uri.js/src/URI.js",
                    "./bower_components/cookies-js/dist/cookies.js",
                    "./bower_components/moment/moment.js",
                    "./bower_components/crypto-js/crypto-js.js"
                ],
                dest: "<%= build.path %>/vendors.js"
            },
            jsorolla: {
                src: [
                    "./lib/jsorolla/src/lib/clients/rest-client.js",
                    "./lib/jsorolla/src/lib/clients/cellbase-client-config.js",
                    "./lib//jsorolla/src/lib/clients/cellbase-client.js",
                    "./lib/jsorolla/src/lib/clients/opencga-client-config.js",
                    "./lib/jsorolla/src/lib/clients/opencga-client.js",
                    "./lib/jsorolla/src/lib/cache/indexeddb-cache.js",
                    "./lib/jsorolla/src/lib/utils.js",
                    "./lib/jsorolla/src/lib/svg.js",
                    "./lib/jsorolla/src/lib/visualisation/lollipop.js",
                    "./lib/jsorolla/src/lib/opencga/variant/variant-utils.js"
                ],
                dest: "<%= build.path %>/jsorolla-clients.js"
            },
            genomeViewer: {
                src: [
                    "./lib/jsorolla/build/2.0.0-beta/genome-viewer/gv-config.js",
                    "./lib/jsorolla/build/2.0.0-beta/genome-viewer/genome-viewer.js"
                ],
                dest: "<%= build.path %>/genome-viewer.js"
            }
        },
        uglify: {
            options: {
                banner: "/*! IVA <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n"
            },
            dist: {
                files: {
                    "<%= build.path %>/vendors.min.js": ["<%= build.path %>/vendors.js"],
                    // '<%= build.path %>/jsorolla.min.js': ['<%= build.path %>/jsorolla-clients.js']
                }
            }
        },
        copy: {
            dist: {
                files: [
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap/dist/css/bootstrap.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-table/dist/bootstrap-table.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-treeview/dist/bootstrap-treeview.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/css/font-awesome.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["qtip2/jquery.qtip.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/fonts/*"], dest: "<%= build.path %>/fonts" },
                    {   flatten: true, expand: true, cwd: "./lib", src: ["jsorolla/styles/css/style.css"], dest: "<%= build.path %>/css" },
                    {   expand: true, cwd: "./bower_components", src: ["polymer/*"], dest: "<%= build.vendor %>" },
                    {   expand: true, cwd: "src", src: ["index.html"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["config.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["panels.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "./", src: ["LICENSE"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["images/*"], dest: "<%= build.path %>/" }
                ]
            }
        },
        processhtml: {
            options: {
                strip: true
            },
            dist: {
                files: {
                    "<%= build.path %>/index.html": ["src/index.html"]
                }
            }
        },
        vulcanize: {
            default: {
                options: {
                    // Task-specific options go here.
                    stripComments: true,
                    excludes: ["bower_components/polymer/polymer.html"]
                },
                files: {
                    "<%= build.path %>/iva-app.html": "src/iva-app.html"
                }
            }
        },
        watch: {
            files: ["<%= jshint.files %>"],
            tasks: ["jshint"]
        },
        replace: {
            dist: {
                options: {
                    patterns: [
                        {
                            match: /\.\.\/bower_components/g,
                            replacement: "vendor"
                        }
                    ]
                },
                files: [
                    {expand: true, flatten: true, src: ["<%= build.path %>/index.html"], dest: "<%= build.path %>"},
                    {expand: true, flatten: true, src: ["<%= build.path %>/iva-app.html"], dest: "<%= build.path %>"},

                ]
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-processhtml");
    grunt.loadNpmTasks("grunt-vulcanize");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-replace");

    grunt.registerTask("default", ["clean", "jshint", "copy", "concat", "uglify", "processhtml", "vulcanize", "replace"]);
    grunt.registerTask("cl", ["clean"]);
};<|endoftext|>


<commit_before>var _ = require('lodash');

module.exports = function(grunt) {
  grunt.initConfig  ({

    less: {
      options: {
        ieCompat: true
      },
      files: {
        expand: true,
        cwd: 'app/less/',
        src: '*.less',
        dest: 'app/css/',
        ext: '.css'
      }
    },

    connect: {
      development: {
        options: {
          port: process.env.PORT || 8083,
          base: './app',
          livereload: true,

          middleware: function(connect, options, middlewares) {
            var morgan = require('morgan')

            middlewares.unshift(morgan('dev'))
            return middlewares;
          }
        }
      },
      heroku: {
        options: {
          port: process.env.PORT,
          base: './app',
          keepalive: true
        }
      }
    },

    watch: {
      css: {
        files: 'app/less/*.less',
        tasks: ['less'],
        options: {
          livereload: true
        }
      },
      template: {
        files: 'app/index.html.template',
        tasks: ['template'],
      },
      config: {
        files: 'config/modulusui*.conf.js',
        tasks: 'config'
      }
    }
  })

  grunt.loadNpmTasks('grunt-contrib-less')
  grunt.loadNpmTasks('grunt-contrib-watch')
  grunt.loadNpmTasks('grunt-contrib-connect')

  grunt.registerTask('default', ['build'])
  grunt.registerTask('serve', ['build', 'connect:development', 'watch'])
  grunt.registerTask('heroku', ['connect:heroku'])
  grunt.registerTask('build', ['config', 'less'])

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

    var config = require('./config/modulusui.conf.js');
    grunt.log.writeln("Including config from modulusui.conf.js");

    if (grunt.file.exists('./config/modulusui-dev.conf.js')) {
      grunt.log.writeln("Including config from modulusui-dev.conf.js");
      var devConfig = require('./config/modulusui-dev.conf.js');
      config = _.assign(config, devConfig);
    }

    if (process.env.MODULUS_UI_CONF) {
      try {
        var override = JSON.parse(process.env.MODULUS_UI_CONF);
        grunt.log.writeln("Including config from environment in MODULUS_UI_CONF");
        config = _.assign(config, override);
      } catch (error) {
        grunt.log.error("Failed to parse configuration in MODULUS_UI_CONF " +
          "environment variable.");
      }
    }

    if (process.env.MODULUS_API_BASE_URL) {
      config.api.baseUrl = process.env.MODULUS_API_BASE_URL;
    }

    if (process.env.MODULUS_API_READ_ONLY) {
      config.api.readOnly = process.env.MODULUS_API_READ_ONLY;
    }

    var contents = "angular.module('modulusOne').constant('Config', " +
      JSON.stringify(config) + ");"
    grunt.file.write('app/js/config.js', contents);

    grunt.log.writeln("Wrote current configuration to app/js/config.js");
  })
}<commit_msg>Watching enabled for html and config files<commit_after>var _ = require('lodash');

module.exports = function(grunt) {
  grunt.initConfig  ({

    less: {
      options: {
        ieCompat: true
      },
      files: {
        expand: true,
        cwd: 'app/less/',
        src: '*.less',
        dest: 'app/css/',
        ext: '.css'
      }
    },

    connect: {
      development: {
        options: {
          port: process.env.PORT || 8083,
          base: './app',
          livereload: true,

          middleware: function(connect, options, middlewares) {
            var morgan = require('morgan')

            middlewares.unshift(morgan('dev'))
            return middlewares;
          }
        }
      },
      heroku: {
        options: {
          port: process.env.PORT,
          base: './app',
          keepalive: true
        }
      }
    },

    watch: {
      css: {
        files: 'app/less/*.less',
        tasks: ['less'],
        options: {
          livereload: true
        }
      },
      templates: {
        files: 'app/**/*.html',
        options: {
          livereload: true
        }
      },
      config: {
        files: 'config/modulusui*.conf.js',
        tasks: 'config',
        options: {
          livereload: true
        }
      }
    }
  })

  grunt.loadNpmTasks('grunt-contrib-less')
  grunt.loadNpmTasks('grunt-contrib-watch')
  grunt.loadNpmTasks('grunt-contrib-connect')

  grunt.registerTask('default', ['build'])
  grunt.registerTask('serve', ['build', 'connect:development', 'watch'])
  grunt.registerTask('heroku', ['connect:heroku'])
  grunt.registerTask('build', ['config', 'less'])

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

    var config = require('./config/modulusui.conf.js');
    grunt.log.writeln("Including config from modulusui.conf.js");

    if (grunt.file.exists('./config/modulusui-dev.conf.js')) {
      grunt.log.writeln("Including config from modulusui-dev.conf.js");
      var devConfig = require('./config/modulusui-dev.conf.js');
      config = _.assign(config, devConfig);
    }

    if (process.env.MODULUS_UI_CONF) {
      try {
        var override = JSON.parse(process.env.MODULUS_UI_CONF);
        grunt.log.writeln("Including config from environment in MODULUS_UI_CONF");
        config = _.assign(config, override);
      } catch (error) {
        grunt.log.error("Failed to parse configuration in MODULUS_UI_CONF " +
          "environment variable.");
      }
    }

    if (process.env.MODULUS_API_BASE_URL) {
      config.api.baseUrl = process.env.MODULUS_API_BASE_URL;
    }

    if (process.env.MODULUS_API_READ_ONLY) {
      config.api.readOnly = process.env.MODULUS_API_READ_ONLY;
    }

    var contents = "angular.module('modulusOne').constant('Config', " +
      JSON.stringify(config) + ");"
    grunt.file.write('app/js/config.js', contents);

    grunt.log.writeln("Wrote current configuration to app/js/config.js");
  })
}<|endoftext|>


<commit_before>module.exports = function(grunt){
    grunt.initConfig({
        pkg:grunt.file.readJSON("bower.json"),
        dir:{
            css:"assets/css",
            js:"assets/js",
            bundles:"assets/bundles",
            tests:"test",
            vendors:"vendor"
        },
        concat:{
            options:{
                stripBanners:true,
                separator:";"
            },
            // Concatenate uncompressed files to create a bundle. Adding already
            // compressed files to this step greatly slows down the minification
            // step (that follows concatenation), without providing any benefits.
            uncompressed:{
                files:{
                    "<%= dir.bundles %>/asset.bundle.core.css":[
                        "<%= dir.css %>/*.css",
                        "!<%= dir.css %>/geotagx-ol.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.core.js":[
                        "<%= dir.js %>/*.js",
                        "!<%= dir.js %>/geotagx-ol.js"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.css":[
                        "<%= dir.css %>/geotagx-ol.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.js":[
                        "<%= dir.js %>/geotagx-ol.js"
                    ]
                }
            },
            // Concatenate the already compressed files to their respective bundles.
            compressed:{
                files:{
                    "<%= dir.bundles %>/asset.bundle.core.css":[
                        "<%= dir.vendors %>/bootstrap-tour/build/css/bootstrap-tour.min.css",
                        "<%= dir.bundles %>/asset.bundle.core.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.core.js":[
                        "<%= dir.vendors %>/bootstrap-tour/build/js/bootstrap-tour.min.js",
                        "<%= dir.bundles %>/asset.bundle.core.js"
                    ],
                    "<%= dir.bundles %>/asset.bundle.datetime.css":[
                        "<%= dir.vendors %>/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.datetime.js":[
                        "<%= dir.vendors %>/moment/min/moment.min.js",
                        "<%= dir.vendors %>/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.css":[
                        "<%= dir.vendors %>/openlayers/ol.css",
                        "<%= dir.bundles %>/asset.bundle.geolocation.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.js":[
                        "<%= dir.vendors %>/openlayers/ol.js",
                        "<%= dir.bundles %>/asset.bundle.geolocation.js"
                    ]
                }
            }
        },
        cssmin:{
            bundles:{
                files:[{
                    expand:true,
                    src:"<%= dir.bundles %>/*.css"
                }]
            }
        },
        uglify:{
            bundles:{
                files:[{
                    expand:true,
                    src:"<%= dir.bundles %>/*.js"
                }]
            }
        },
        jshint:{
            files:[
                "Gruntfile.js",
                "static/js/*.js",
                "test/**/*.js"
            ],
            options:{
                globals:{
                    console:true,
                    module:true,
                    document:true
                }
            }
        },
        qunit:{
            options:{
                force:true //TODO Remove when at least one test is implemented.
            },
            testsuite:"<%= dir.tests %>/**/*.html"
        }
    });
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-qunit");
    grunt.loadNpmTasks("grunt-contrib-uglify");

    grunt.registerTask("test",    ["jshint","qunit"]);
    grunt.registerTask("bundle",  ["concat:uncompressed","cssmin","uglify","concat:compressed"]);
    grunt.registerTask("default", ["test","bundle"]);
};
<commit_msg>Remove semi-colon separator<commit_after>module.exports = function(grunt){
    grunt.initConfig({
        pkg:grunt.file.readJSON("bower.json"),
        dir:{
            css:"assets/css",
            js:"assets/js",
            bundles:"assets/bundles",
            tests:"test",
            vendors:"vendor"
        },
        concat:{
            options:{
                stripBanners:true
            },
            // Concatenate uncompressed files to create a bundle. Adding already
            // compressed files to this step greatly slows down the minification
            // step (that follows concatenation), without providing any benefits.
            uncompressed:{
                files:{
                    "<%= dir.bundles %>/asset.bundle.core.css":[
                        "<%= dir.css %>/*.css",
                        "!<%= dir.css %>/geotagx-ol.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.core.js":[
                        "<%= dir.js %>/*.js",
                        "!<%= dir.js %>/geotagx-ol.js"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.css":[
                        "<%= dir.css %>/geotagx-ol.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.js":[
                        "<%= dir.js %>/geotagx-ol.js"
                    ]
                }
            },
            // Concatenate the already compressed files to their respective bundles.
            compressed:{
                files:{
                    "<%= dir.bundles %>/asset.bundle.core.css":[
                        "<%= dir.vendors %>/bootstrap-tour/build/css/bootstrap-tour.min.css",
                        "<%= dir.bundles %>/asset.bundle.core.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.core.js":[
                        "<%= dir.vendors %>/bootstrap-tour/build/js/bootstrap-tour.min.js",
                        "<%= dir.bundles %>/asset.bundle.core.js"
                    ],
                    "<%= dir.bundles %>/asset.bundle.datetime.css":[
                        "<%= dir.vendors %>/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.datetime.js":[
                        "<%= dir.vendors %>/moment/min/moment.min.js",
                        "<%= dir.vendors %>/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.css":[
                        "<%= dir.vendors %>/openlayers/ol.css",
                        "<%= dir.bundles %>/asset.bundle.geolocation.css"
                    ],
                    "<%= dir.bundles %>/asset.bundle.geolocation.js":[
                        "<%= dir.vendors %>/openlayers/ol.js",
                        "<%= dir.bundles %>/asset.bundle.geolocation.js"
                    ]
                }
            }
        },
        cssmin:{
            bundles:{
                files:[{
                    expand:true,
                    src:"<%= dir.bundles %>/*.css"
                }]
            }
        },
        uglify:{
            bundles:{
                files:[{
                    expand:true,
                    src:"<%= dir.bundles %>/*.js"
                }]
            }
        },
        jshint:{
            files:[
                "Gruntfile.js",
                "static/js/*.js",
                "test/**/*.js"
            ],
            options:{
                globals:{
                    console:true,
                    module:true,
                    document:true
                }
            }
        },
        qunit:{
            options:{
                force:true //TODO Remove when at least one test is implemented.
            },
            testsuite:"<%= dir.tests %>/**/*.html"
        }
    });
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-qunit");
    grunt.loadNpmTasks("grunt-contrib-uglify");

    grunt.registerTask("test",    ["jshint","qunit"]);
    grunt.registerTask("bundle",  ["concat:uncompressed","cssmin","uglify","concat:compressed"]);
    grunt.registerTask("default", ["test","bundle"]);
};
<|endoftext|>


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

  'use strict';

  require( 'time-grunt' )( grunt );
  require( 'jit-grunt' )( grunt, {
    // Static mappings below;
    // needed because task name does not match package name.
    bower: 'grunt-bower-task',
    usebanner: 'grunt-banner'
  } );

  var path = require('path');

  // Allows a `--quiet` flag to be passed to Grunt from the command-line.
  // If the flag is present the value is true, otherwise it is false.
  // This flag can be used to, for example, suppress warning output
  // from linters.
  var env = {
    quiet: grunt.option('quiet') ? true : false
  };

  var config = {

    /**
     * Pull in the package.json file so we can read its metadata.
     */
    pkg: grunt.file.readJSON('bower.json'),

    /**
     * Set directory location variables.
     */
    loc: {
      src:  './src',
      dist: './dist',
      lib:  grunt.file.readJSON('./.bowerrc').directory,
      test: './test'
    },

    /**
     * Bower: https://github.com/yatskevich/grunt-bower-task
     *
     * Migrate static assets to distribution directory.
     */
    bower: {
      process: {
        options: {
          targetDir: '<%= loc.lib %>',
          install: false,
          cleanTargetDir: false,
          // The `exportsOverride` section in `bower.json` is used to map
          // bower package components to types (js, css, less, img, fonts),
          // which can then be moved in the `layout` function below.
          //
          // TODO: Switch to maintained grunt bower task.
          // There is a bug in the `grunt-bower-task` which means
          // certain packages have to appear in the `exportsOverride`
          // section, even though they are only being copied in place.
          // This has occurred with the `history.js`,
          // and `string_score` packages. The consequence of this is that
          // they are listed in `bower.json` and in the `browser` field
          // in `package.json` when it shouldn't be necessary to list them
          // in both places.
          // Unfortunately, the `grunt-bower-task` is not being maintained
          // as of May, 2015, so this likely will not be fixed soon.
          // See background in issue:
          // https://github.com/yatskevich/grunt-bower-task/issues/159
          layout: function( type, component, source ) {
            var lib = config.loc.lib;
            var dist = config.loc.dist + '/static/';
            var assetPath = component;
            if ( ( type === 'img' || type === 'fonts' ) ||
                 ( type === 'js' && component === 'box-sizing-polyfill' ) ||
                 ( type === 'css' && component === 'slick-carousel' ) ||
                 ( type === 'js' && component === 'html5shiv') ) {
              assetPath = path.relative( lib , dist + type );
              grunt.log.writeln('Moving ./' + source + ' to ' + dist + type);
            }
            return assetPath;
          }
        }
      }
    },

    /**
     * String replace: https://github.com/erickrdch/grunt-string-replace
     *
     * Replace strings on files by using string or regex patters.
     */
    // TODO: Prefix replacement URLs with <%= loc.dist %> when `/dist`
    // directory exists.
    'string-replace': {
      chosen: {
        files: {
          '<%= loc.lib %>/chosen/': '<%= loc.lib %>/chosen/chosen.css'
        },
        options: {
          replacements: [{
            pattern: /url\('chosen-sprite.png'\)/ig,
            replacement: 'url("/static/img/chosen-sprite.png")'
          },
          {
            pattern: /url\('chosen-sprite@2x.png'\)/ig,
            replacement: 'url("/static/img/chosen-sprite@2x.png")'
          }]
        }
      },
      'slick-carousel': {
        files: {
          '<%= loc.dist %>/static/css/': '<%= loc.dist %>/static/css/slick.css'
        },
        options: {
          replacements: [{
            pattern: /url\(".\/ajax-loader.gif"\)/ig,
            replacement: 'url("/static/img/ajax-loader.gif")'
          }]
        }
      }
    },

    /**
     * Concat: https://github.com/gruntjs/grunt-contrib-concat
     *
     * Concatenate cf-* Less files prior to compiling them.
     */
    concat: {
      'cf-less': {
        src: [
          '<%= loc.lib %>/cf-*/*.less',
          '!<%= loc.lib %>/cf-core/*.less',
          '<%= loc.lib %>/cf-core/cf-core.less'
        ],
        dest: '<%= loc.lib %>/capital-framework/capital-framework.less',
        nonull: true
      }
    },

    /**
     * Less: https://github.com/gruntjs/grunt-contrib-less
     *
     * Compile Less files to CSS.
     */
    less: {
      main: {
        options: {
          // Specifies directories to scan for @import directives when parsing.
          // Additional paths can be passed to the array in `concat()`.
          paths: function( source ) {
            grunt.log.writeln( 'Processing ' + source );
            return grunt.file.expand( config.loc.lib + '/*' ).concat([])
          },
          compress: true,
          sourceMap: true,
          // Where the sourcemap file is generated and located.
          sourceMapFilename: '<%= loc.dist %>/static/css/main.css.map',
          // The complete URL and sourcemap filename put in the compiled CSS file.
          sourceMapURL: 'main.css.map',
        },
        files: {
          '<%= loc.dist %>/static/css/main.css': ['<%= loc.src %>/static/css/main.less']
        }
      }
    },

    /**
     * Autoprefixer: https://github.com/nDmitry/grunt-autoprefixer
     *
     * Parse CSS and add vendor-prefixed CSS properties using the Can I Use database.
     */
    autoprefixer: {
      options: {
        // Options we might want to enable in the future.
        diff: false,
        map: false
      },
      main: {
        // Prefix `static/css/main.css` and overwrite.
        expand: true,
        src: ['<%= loc.dist %>/static/css/main.css']
      },
    },

    /**
     * Browserify: https://github.com/jmreidy/grunt-browserify
     *
     * CommonJS JavaScript module manager.
     * Shared modules are in `common.js`, while page-specific
     * modules are in scripts that mirror the name of the
     * URL location path, but ending in `index.js`.
     */
    browserify: {
      build: {
        src: '<%= loc.src %>/static/js/routes/**/*.js',
        dest: '<%= loc.dist %>/static/js/routes/common.min.js'
      },
      options: {
        // Note: The transforms for minification and
        // the entire `browserify-shim` config is inside `package.json`.
      }
    },

    /**
     * Banner: https://github.com/mattstyles/grunt-banner
     *
     * Here's a banner with some template variables.
     * We'll be inserting it at the top of minified assets.
     */
    banner:
      '/*!\n' +
      ' *               ad$$               $$\n' +
      ' *              d$"                 $$\n' +
      ' *              $$                  $$\n' +
      ' *   ,adPYba.   $$$$$  $$.,dPYba.   $$.,dPYba.\n' +
      ' *  aP′    `$:  $$     $$P′    `$a  $$P′    `$a\n' +
      ' *  $(          $$     $$(      )$  $$(      )$\n' +
      ' *  "b.    ,$:  $$     $$b.    ,$"  $$b.    ,$"\n' +
      ' *   `"Ybd$"′   $$     $$`"YbdP"′   $$`"YbdP"′\n' +
      ' *                     $$\n' +
      ' *                     $$\n' +
      ' *                     $$\n' +
      ' *\n' +
      ' *  <%= pkg.name %> - v<%= pkg.version %>\n' +
      ' *  <%= pkg.homepage %>\n' +
      ' *  A public domain work of the Consumer Financial Protection Bureau\n' +
      ' */',

    usebanner: {
      css: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/css/*.min.css']
        }
      },
      js: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/js/routes/*.min.js']
        }
      }
    },

    /**
     * Legacssy: https://github.com/robinpokorny/grunt-legacssy
     *
     * Fix your CSS for legacy browsers.
     */
    legacssy: {
      'ie-alternate': {
        options: {
          // Flatten all media queries with a min-width over 960 or lower.
          // All media queries over 960 will be excluded from the stylesheet.
          // EM calculation: 960 / 16 = 60
          legacyWidth: 60
        },
        files: {
          '<%= loc.dist %>/static/css/main.ie.css': '<%= loc.dist %>/static/css/main.css'
        }
      }
    },

    /**
     * Clean: https://github.com/gruntjs/grunt-contrib-clean
     *
     * Clean files and folders
     */
    clean: ['dist'],

    /**
     * Copy: https://github.com/gruntjs/grunt-contrib-copy
     *
     * Copy files and folders.
     */
    copy: {
      main: {
        files: [
          {
            expand: true,
            cwd: '<%= loc.src %>',
            src: [
              // HTML, templates, and config.
              '**/*.html',
              '_*/*',
              'static-legacy/**/*',
              'robots.txt',
              '!vendor/**/*.html'
            ],
            dest: '<%= loc.dist %>'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // JSON.
              '<%= loc.src %>/_settings/mappings/*'
            ],
            dest: '<%= loc.dist %>/_settings/mappings/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // CSS.
              '<%= loc.src %>/static/css/pdfreactor-fonts.css'
            ],
            dest: '<%= loc.dist %>/static/css/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // JavaScript.
              '<%= loc.lib %>/box-sizing-polyfill/boxsizing.htc',
              '<%= loc.lib %>/html5shiv/dist/html5shiv-printshiv.min.js'
            ],
            dest: '<%= loc.dist %>/static/js/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // Images.
              '<%= loc.src %>/static/img/**/*'
            ],
            dest: '<%= loc.dist %>/static/img/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // Fonts.
              '<%= loc.lib %>/cf-icons/src/fonts/*'
            ],
            dest: '<%= loc.dist %>/static/fonts/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // Fonts - PDFReactor.
              // TODO: See how to combine this with the above,
              //       while preserving the /pdfreactor/ directory.
              '<%= loc.src %>/static/fonts/pdfreactor/*'
            ],
            dest: '<%= loc.dist %>/static/fonts/pdfreactor'
          },
        ]
      }
    },

    /**
     * Lint the JavaScript.
     */
    lintjs: {
      /**
       * Validate files with ESLint.
       * https://www.npmjs.com/package/grunt-contrib-eslint
       */
      eslint: {
        options: {
            quiet: env.quiet
        },
        src: [
            '<%= loc.src %>/static/js/**/*.js',
            '<%= loc.test %>/unit_tests/**/*.js',
            '<%= loc.test %>/browser_tests/**/*.js'
        ]
      }
    },

    /**
     * Mocha_istanbul: Run mocha tests and spit out code coverage
     */
    mocha_istanbul: {
      coverage: {
        src: ['<%= loc.test %>/unit_tests/**/*.js'],
        options: {
          coverageFolder: '<%= loc.test %>/unit_test_coverage',
          excludes: ['<%= loc.test %>/unit_tests/**/*.js']
        }
      }
    },

    /**
     * Watch: https://github.com/gruntjs/grunt-contrib-watch
     *
     * Run predefined tasks whenever watched file patterns are added, changed or deleted.
     * Add files to monitor below.
     */
    watch: {
      all: {
        files: ['<%= loc.src %>/static/css/*.less', '<%= loc.src %>/static/js/**/*.js', 'Gruntfile.js'],
        tasks: ['default']
      },
      cssjs: {
        files: ['<%= loc.src %>/static/css/*.less', '<%= loc.src %>/static/js/**/*.js'],
        tasks: ['css', 'js']
      },
      css: {
        files: ['<%= loc.src %>/static/css/**/*.less'],
        tasks: ['css']
      },
      js: {
        files: ['<%= loc.src %>/static/js/**/*.js'],
        tasks: ['js']
      }
    },

    /**
     * See note below about creating a dynamic Topdoc options object.
     */
    topdoc_families: [
      'blog-docs',
      'calendar-icon',
      'cf-enhancements',
      'event-docs',
      'event-meta',
      'forms',
      'header',
      'lists',
      'media',
      'meta',
      'misc',
      'nav-secondary',
      'post',
      'print',
      'summary'
    ]
  };

  /**
   * TODO: /docs/ directory is not currently in use. This task will likely
   *       need to be updated in the future.
   * Creates a dynamic Topdoc options object.
   * To add more subtasks add an item to the config.topdoc_families array.
   * For example if you created a new component with the family name of
   * "my-component" then you could add a new item to the config.topdoc_families
   * array called "my-component" and this function would automatically add a new
   * Topdoc subtask to the Topdoc task. You could then run `grunt topdoc:my-component`
   * to build it out separately or just `grunt topdoc` to run all topdoc tasks.
   */
  function dynamicTopdocTasks() {
    var topdoc = {},
        families = config.topdoc_families;
    for (var i = 0; i < families.length; i++) {
      var key = families[i];
      topdoc[key] = {
        options: {
          source: '<%= loc.dist %>/static/css/',
          destination: 'docs/' + key + '/',
          template: 'node_modules/cf-component-demo/docs/',
          templateData: {
            family: 'cfgov-' + key,
            description: key + ' for cfgov-refresh.',
            title: 'cfgov-refresh / ' + key + ' docs',
            repo: '<%= pkg.homepage %>'
          }
        }
      };
    }
    return topdoc;
  }

  // TODO: `grunt topdoc` task is currently unused, the idea is docs would
  // be deployed to the gh-pages branch only. However, this is not currently
  // set up. The task used will be `concurrent:topdoc`, which is set up below.
  config.topdoc = dynamicTopdocTasks();

  /**
   * Create an array of all of the Topdoc subtasks.
   * This is useful for the concurrent task which needs to know all of the
   * tasks you want to run concurrently. Since these Topdics are dynamically
   * created we need a way to also dynamically update the concurrent task options.
   */
  function getTopdocSubtasks() {
    var families = config.topdoc_families,
        subtasks = [];
    for (var i = 0; i < families.length; i++) {
      subtasks.push( 'topdoc:' + families[i] );
    }
    return subtasks;
  }

  config.concurrent = {
    topdoc: getTopdocSubtasks()
  };

  /**
   * Initialize a configuration object for the current project.
   */
  grunt.initConfig(config);

  /**
   * Create custom task aliases and combinations.
   */
  grunt.registerTask('vendor', ['bower:process', 'string-replace:chosen',
                                'string-replace:slick-carousel', 'concat:cf-less']);
  grunt.registerTask('css', ['less', 'autoprefixer', 'legacssy', 'usebanner:css']);
  grunt.registerTask('js', ['browserify:build', 'usebanner:js']);
  grunt.registerTask('test', ['lintjs', 'mocha_istanbul']);
  grunt.registerMultiTask('lintjs', 'Lint the JavaScript', function(){
    grunt.config.set(this.target, this.data);
    grunt.task.run(this.target);
  });
  grunt.registerTask('build', ['vendor', 'test', 'css', 'js', 'copy']);
  grunt.registerTask('default', ['build']);
};
<commit_msg>Adds a `grunt watch` config to watch for changes to .html files, and execute the copy task<commit_after>module.exports = function(grunt) {

  'use strict';

  require( 'time-grunt' )( grunt );
  require( 'jit-grunt' )( grunt, {
    // Static mappings below;
    // needed because task name does not match package name.
    bower: 'grunt-bower-task',
    usebanner: 'grunt-banner'
  } );

  var path = require('path');

  // Allows a `--quiet` flag to be passed to Grunt from the command-line.
  // If the flag is present the value is true, otherwise it is false.
  // This flag can be used to, for example, suppress warning output
  // from linters.
  var env = {
    quiet: grunt.option('quiet') ? true : false
  };

  var config = {

    /**
     * Pull in the package.json file so we can read its metadata.
     */
    pkg: grunt.file.readJSON('bower.json'),

    /**
     * Set directory location variables.
     */
    loc: {
      src:  './src',
      dist: './dist',
      lib:  grunt.file.readJSON('./.bowerrc').directory,
      test: './test'
    },

    /**
     * Bower: https://github.com/yatskevich/grunt-bower-task
     *
     * Migrate static assets to distribution directory.
     */
    bower: {
      process: {
        options: {
          targetDir: '<%= loc.lib %>',
          install: false,
          cleanTargetDir: false,
          // The `exportsOverride` section in `bower.json` is used to map
          // bower package components to types (js, css, less, img, fonts),
          // which can then be moved in the `layout` function below.
          //
          // TODO: Switch to maintained grunt bower task.
          // There is a bug in the `grunt-bower-task` which means
          // certain packages have to appear in the `exportsOverride`
          // section, even though they are only being copied in place.
          // This has occurred with the `history.js`,
          // and `string_score` packages. The consequence of this is that
          // they are listed in `bower.json` and in the `browser` field
          // in `package.json` when it shouldn't be necessary to list them
          // in both places.
          // Unfortunately, the `grunt-bower-task` is not being maintained
          // as of May, 2015, so this likely will not be fixed soon.
          // See background in issue:
          // https://github.com/yatskevich/grunt-bower-task/issues/159
          layout: function( type, component, source ) {
            var lib = config.loc.lib;
            var dist = config.loc.dist + '/static/';
            var assetPath = component;
            if ( ( type === 'img' || type === 'fonts' ) ||
                 ( type === 'js' && component === 'box-sizing-polyfill' ) ||
                 ( type === 'css' && component === 'slick-carousel' ) ||
                 ( type === 'js' && component === 'html5shiv') ) {
              assetPath = path.relative( lib , dist + type );
              grunt.log.writeln('Moving ./' + source + ' to ' + dist + type);
            }
            return assetPath;
          }
        }
      }
    },

    /**
     * String replace: https://github.com/erickrdch/grunt-string-replace
     *
     * Replace strings on files by using string or regex patters.
     */
    // TODO: Prefix replacement URLs with <%= loc.dist %> when `/dist`
    // directory exists.
    'string-replace': {
      chosen: {
        files: {
          '<%= loc.lib %>/chosen/': '<%= loc.lib %>/chosen/chosen.css'
        },
        options: {
          replacements: [{
            pattern: /url\('chosen-sprite.png'\)/ig,
            replacement: 'url("/static/img/chosen-sprite.png")'
          },
          {
            pattern: /url\('chosen-sprite@2x.png'\)/ig,
            replacement: 'url("/static/img/chosen-sprite@2x.png")'
          }]
        }
      },
      'slick-carousel': {
        files: {
          '<%= loc.dist %>/static/css/': '<%= loc.dist %>/static/css/slick.css'
        },
        options: {
          replacements: [{
            pattern: /url\(".\/ajax-loader.gif"\)/ig,
            replacement: 'url("/static/img/ajax-loader.gif")'
          }]
        }
      }
    },

    /**
     * Concat: https://github.com/gruntjs/grunt-contrib-concat
     *
     * Concatenate cf-* Less files prior to compiling them.
     */
    concat: {
      'cf-less': {
        src: [
          '<%= loc.lib %>/cf-*/*.less',
          '!<%= loc.lib %>/cf-core/*.less',
          '<%= loc.lib %>/cf-core/cf-core.less'
        ],
        dest: '<%= loc.lib %>/capital-framework/capital-framework.less',
        nonull: true
      }
    },

    /**
     * Less: https://github.com/gruntjs/grunt-contrib-less
     *
     * Compile Less files to CSS.
     */
    less: {
      main: {
        options: {
          // Specifies directories to scan for @import directives when parsing.
          // Additional paths can be passed to the array in `concat()`.
          paths: function( source ) {
            grunt.log.writeln( 'Processing ' + source );
            return grunt.file.expand( config.loc.lib + '/*' ).concat([])
          },
          compress: true,
          sourceMap: true,
          // Where the sourcemap file is generated and located.
          sourceMapFilename: '<%= loc.dist %>/static/css/main.css.map',
          // The complete URL and sourcemap filename put in the compiled CSS file.
          sourceMapURL: 'main.css.map',
        },
        files: {
          '<%= loc.dist %>/static/css/main.css': ['<%= loc.src %>/static/css/main.less']
        }
      }
    },

    /**
     * Autoprefixer: https://github.com/nDmitry/grunt-autoprefixer
     *
     * Parse CSS and add vendor-prefixed CSS properties using the Can I Use database.
     */
    autoprefixer: {
      options: {
        // Options we might want to enable in the future.
        diff: false,
        map: false
      },
      main: {
        // Prefix `static/css/main.css` and overwrite.
        expand: true,
        src: ['<%= loc.dist %>/static/css/main.css']
      },
    },

    /**
     * Browserify: https://github.com/jmreidy/grunt-browserify
     *
     * CommonJS JavaScript module manager.
     * Shared modules are in `common.js`, while page-specific
     * modules are in scripts that mirror the name of the
     * URL location path, but ending in `index.js`.
     */
    browserify: {
      build: {
        src: '<%= loc.src %>/static/js/routes/**/*.js',
        dest: '<%= loc.dist %>/static/js/routes/common.min.js'
      },
      options: {
        // Note: The transforms for minification and
        // the entire `browserify-shim` config is inside `package.json`.
      }
    },

    /**
     * Banner: https://github.com/mattstyles/grunt-banner
     *
     * Here's a banner with some template variables.
     * We'll be inserting it at the top of minified assets.
     */
    banner:
      '/*!\n' +
      ' *               ad$$               $$\n' +
      ' *              d$"                 $$\n' +
      ' *              $$                  $$\n' +
      ' *   ,adPYba.   $$$$$  $$.,dPYba.   $$.,dPYba.\n' +
      ' *  aP′    `$:  $$     $$P′    `$a  $$P′    `$a\n' +
      ' *  $(          $$     $$(      )$  $$(      )$\n' +
      ' *  "b.    ,$:  $$     $$b.    ,$"  $$b.    ,$"\n' +
      ' *   `"Ybd$"′   $$     $$`"YbdP"′   $$`"YbdP"′\n' +
      ' *                     $$\n' +
      ' *                     $$\n' +
      ' *                     $$\n' +
      ' *\n' +
      ' *  <%= pkg.name %> - v<%= pkg.version %>\n' +
      ' *  <%= pkg.homepage %>\n' +
      ' *  A public domain work of the Consumer Financial Protection Bureau\n' +
      ' */',

    usebanner: {
      css: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/css/*.min.css']
        }
      },
      js: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/js/routes/*.min.js']
        }
      }
    },

    /**
     * Legacssy: https://github.com/robinpokorny/grunt-legacssy
     *
     * Fix your CSS for legacy browsers.
     */
    legacssy: {
      'ie-alternate': {
        options: {
          // Flatten all media queries with a min-width over 960 or lower.
          // All media queries over 960 will be excluded from the stylesheet.
          // EM calculation: 960 / 16 = 60
          legacyWidth: 60
        },
        files: {
          '<%= loc.dist %>/static/css/main.ie.css': '<%= loc.dist %>/static/css/main.css'
        }
      }
    },

    /**
     * Clean: https://github.com/gruntjs/grunt-contrib-clean
     *
     * Clean files and folders
     */
    clean: ['dist'],

    /**
     * Copy: https://github.com/gruntjs/grunt-contrib-copy
     *
     * Copy files and folders.
     */
    copy: {
      main: {
        files: [
          {
            expand: true,
            cwd: '<%= loc.src %>',
            src: [
              // HTML, templates, and config.
              '**/*.html',
              '_*/*',
              'static-legacy/**/*',
              'robots.txt',
              '!vendor/**/*.html'
            ],
            dest: '<%= loc.dist %>'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // JSON.
              '<%= loc.src %>/_settings/mappings/*'
            ],
            dest: '<%= loc.dist %>/_settings/mappings/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // CSS.
              '<%= loc.src %>/static/css/pdfreactor-fonts.css'
            ],
            dest: '<%= loc.dist %>/static/css/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // JavaScript.
              '<%= loc.lib %>/box-sizing-polyfill/boxsizing.htc',
              '<%= loc.lib %>/html5shiv/dist/html5shiv-printshiv.min.js'
            ],
            dest: '<%= loc.dist %>/static/js/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // Images.
              '<%= loc.src %>/static/img/**/*'
            ],
            dest: '<%= loc.dist %>/static/img/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // Fonts.
              '<%= loc.lib %>/cf-icons/src/fonts/*'
            ],
            dest: '<%= loc.dist %>/static/fonts/'
          },
          {
            expand: true,
            flatten: true,
            src: [
              // Fonts - PDFReactor.
              // TODO: See how to combine this with the above,
              //       while preserving the /pdfreactor/ directory.
              '<%= loc.src %>/static/fonts/pdfreactor/*'
            ],
            dest: '<%= loc.dist %>/static/fonts/pdfreactor'
          },
        ]
      }
    },

    /**
     * Lint the JavaScript.
     */
    lintjs: {
      /**
       * Validate files with ESLint.
       * https://www.npmjs.com/package/grunt-contrib-eslint
       */
      eslint: {
        options: {
            quiet: env.quiet
        },
        src: [
            '<%= loc.src %>/static/js/**/*.js',
            '<%= loc.test %>/unit_tests/**/*.js',
            '<%= loc.test %>/browser_tests/**/*.js'
        ]
      }
    },

    /**
     * Mocha_istanbul: Run mocha tests and spit out code coverage
     */
    mocha_istanbul: {
      coverage: {
        src: ['<%= loc.test %>/unit_tests/**/*.js'],
        options: {
          coverageFolder: '<%= loc.test %>/unit_test_coverage',
          excludes: ['<%= loc.test %>/unit_tests/**/*.js']
        }
      }
    },

    /**
     * Watch: https://github.com/gruntjs/grunt-contrib-watch
     *
     * Run predefined tasks whenever watched file patterns are added, changed or deleted.
     * Add files to monitor below.
     */
    watch: {
      all: {
        files: ['<%= loc.src %>/static/css/*.less', '<%= loc.src %>/static/js/**/*.js', 'Gruntfile.js'],
        tasks: ['default']
      },
      cssjs: {
        files: ['<%= loc.src %>/static/css/*.less', '<%= loc.src %>/static/js/**/*.js'],
        tasks: ['css', 'js']
      },
      css: {
        files: ['<%= loc.src %>/static/css/**/*.less'],
        tasks: ['css']
      },
      js: {
        files: ['<%= loc.src %>/static/js/**/*.js'],
        tasks: ['js']
      },
      jinja2: {
        files: ['<%= loc.src %>/**/*.html'],
        tasks: ['copy']
      }
    },

    /**
     * See note below about creating a dynamic Topdoc options object.
     */
    topdoc_families: [
      'blog-docs',
      'calendar-icon',
      'cf-enhancements',
      'event-docs',
      'event-meta',
      'forms',
      'header',
      'lists',
      'media',
      'meta',
      'misc',
      'nav-secondary',
      'post',
      'print',
      'summary'
    ]
  };

  /**
   * TODO: /docs/ directory is not currently in use. This task will likely
   *       need to be updated in the future.
   * Creates a dynamic Topdoc options object.
   * To add more subtasks add an item to the config.topdoc_families array.
   * For example if you created a new component with the family name of
   * "my-component" then you could add a new item to the config.topdoc_families
   * array called "my-component" and this function would automatically add a new
   * Topdoc subtask to the Topdoc task. You could then run `grunt topdoc:my-component`
   * to build it out separately or just `grunt topdoc` to run all topdoc tasks.
   */
  function dynamicTopdocTasks() {
    var topdoc = {},
        families = config.topdoc_families;
    for (var i = 0; i < families.length; i++) {
      var key = families[i];
      topdoc[key] = {
        options: {
          source: '<%= loc.dist %>/static/css/',
          destination: 'docs/' + key + '/',
          template: 'node_modules/cf-component-demo/docs/',
          templateData: {
            family: 'cfgov-' + key,
            description: key + ' for cfgov-refresh.',
            title: 'cfgov-refresh / ' + key + ' docs',
            repo: '<%= pkg.homepage %>'
          }
        }
      };
    }
    return topdoc;
  }

  // TODO: `grunt topdoc` task is currently unused, the idea is docs would
  // be deployed to the gh-pages branch only. However, this is not currently
  // set up. The task used will be `concurrent:topdoc`, which is set up below.
  config.topdoc = dynamicTopdocTasks();

  /**
   * Create an array of all of the Topdoc subtasks.
   * This is useful for the concurrent task which needs to know all of the
   * tasks you want to run concurrently. Since these Topdics are dynamically
   * created we need a way to also dynamically update the concurrent task options.
   */
  function getTopdocSubtasks() {
    var families = config.topdoc_families,
        subtasks = [];
    for (var i = 0; i < families.length; i++) {
      subtasks.push( 'topdoc:' + families[i] );
    }
    return subtasks;
  }

  config.concurrent = {
    topdoc: getTopdocSubtasks()
  };

  /**
   * Initialize a configuration object for the current project.
   */
  grunt.initConfig(config);

  /**
   * Create custom task aliases and combinations.
   */
  grunt.registerTask('vendor', ['bower:process', 'string-replace:chosen',
                                'string-replace:slick-carousel', 'concat:cf-less']);
  grunt.registerTask('css', ['less', 'autoprefixer', 'legacssy', 'usebanner:css']);
  grunt.registerTask('js', ['browserify:build', 'usebanner:js']);
  grunt.registerTask('test', ['lintjs', 'mocha_istanbul']);
  grunt.registerMultiTask('lintjs', 'Lint the JavaScript', function(){
    grunt.config.set(this.target, this.data);
    grunt.task.run(this.target);
  });
  grunt.registerTask('build', ['vendor', 'test', 'css', 'js', 'copy']);
  grunt.registerTask('default', ['build']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt){
  grunt.initConfig({
    // Clean
    clean: ['public', 'govuk_modules'],

    // Builds Sass
    sass: {
      dev: {
        options: {
          style: "expanded",
          sourcemap: true,
          includePaths: [
            'govuk_modules/govuk_template/assets/stylesheets',
            'govuk_modules/govuk_frontend_toolkit/stylesheets'
          ],
          outputStyle: 'expanded'
        },
        files: [{
          expand: true,
          cwd: "app/assets/sass",
          src: ["*.scss"],
          dest: "public/stylesheets/",
          ext: ".css"
        }]
      }
    },

    // Copies templates and assets from external modules and dirs
    copy: {
      assets: {
        files: [{
          expand: true,
          cwd: 'app/assets/',
          src: ['**/*', '!sass/**'],
          dest: 'public/'
        }]
      },
      govuk: {
        files: [{
          expand: true,
          cwd: 'node_modules/govuk_frontend_toolkit',
          src: '**',
          dest: 'govuk_modules/govuk_frontend_toolkit/'
        },
        {
          expand: true,
          cwd: 'node_modules/govuk_template_mustache/',
          src: '**',
          dest: 'govuk_modules/govuk_template/'
        },
        {
          expand: true,
          cwd: 'node_modules/govuk_template_jinja/',
          src: '**',
          dest: 'govuk_modules/govuk_template_jinja/'
        }]
      },
      govuk_template_jinja: {
        files: [{
          expand: true,
          cwd: 'govuk_modules/govuk_template_jinja/views/layouts/',
          src: '**',
          dest: 'lib/'
        }]
      },
    },

    // Watches assets and sass for changes
    watch: {
      css: {
        files: ['app/assets/sass/**/*.scss'],
        tasks: ['sass'],
        options: {
          spawn: false,
        }
      },
      assets:{
        files: ['app/assets/**/*', '!app/assets/sass/**'],
        tasks: ['copy:assets'],
        options: {
          spawn: false,
        }
      }
    },

    // nodemon watches for changes and restarts app
    nodemon: {
      dev: {
        script: 'server.js',
        options: {
          ext: 'js, json, html',
          ignore: ['node_modules/**', 'app/assets/**', 'public/**'],
          args: grunt.option.flags()
        }
      }
    },

    concurrent: {
        target: {
            tasks: ['watch', 'nodemon'],
            options: {
                logConcurrentOutput: true
            }
        }
    }
  });

  [
    'grunt-contrib-copy',
    'grunt-contrib-watch',
    'grunt-contrib-clean',
    'grunt-sass',
    'grunt-nodemon',
    'grunt-concurrent'
  ].forEach(function (task) {
    grunt.loadNpmTasks(task);
  });

  grunt.registerTask('generate-assets', [
    'clean',
    'copy',
    'sass'
  ]);

  grunt.registerTask('default', [
    'generate-assets',
    'concurrent:target'
  ]);

  grunt.registerTask(
    'test',
    'default',
    function () {
      grunt.log.writeln('Test that the app runs');
    }
  );

  grunt.event.on('watch', function(action, filepath, target) {

    // just copy the asset that was changed, not all of them

    if (target == "assets"){
      grunt.config('copy.assets.files.0.src', filepath.replace("app/assets/",""));
    }

  });

};
<commit_msg>Only copy assets from the mustache version of the template<commit_after>module.exports = function(grunt){
  grunt.initConfig({
    // Clean
    clean: ['public', 'govuk_modules'],

    // Builds Sass
    sass: {
      dev: {
        options: {
          style: "expanded",
          sourcemap: true,
          includePaths: [
            'govuk_modules/govuk_template/assets/stylesheets',
            'govuk_modules/govuk_frontend_toolkit/stylesheets'
          ],
          outputStyle: 'expanded'
        },
        files: [{
          expand: true,
          cwd: "app/assets/sass",
          src: ["*.scss"],
          dest: "public/stylesheets/",
          ext: ".css"
        }]
      }
    },

    // Copies templates and assets from external modules and dirs
    copy: {
      assets: {
        files: [{
          expand: true,
          cwd: 'app/assets/',
          src: ['**/*', '!sass/**'],
          dest: 'public/'
        }]
      },
      govuk: {
        files: [{
          expand: true,
          cwd: 'node_modules/govuk_frontend_toolkit',
          src: '**',
          dest: 'govuk_modules/govuk_frontend_toolkit/'
        },
        {
          expand: true,
          cwd: 'node_modules/govuk_template_mustache/assets/',
          src: '**',
          dest: 'govuk_modules/govuk_template/assets/'
        },
        {
          expand: true,
          cwd: 'node_modules/govuk_template_jinja/',
          src: '**',
          dest: 'govuk_modules/govuk_template_jinja/'
        }]
      },
      govuk_template_jinja: {
        files: [{
          expand: true,
          cwd: 'govuk_modules/govuk_template_jinja/views/layouts/',
          src: '**',
          dest: 'lib/'
        }]
      },
    },

    // Watches assets and sass for changes
    watch: {
      css: {
        files: ['app/assets/sass/**/*.scss'],
        tasks: ['sass'],
        options: {
          spawn: false,
        }
      },
      assets:{
        files: ['app/assets/**/*', '!app/assets/sass/**'],
        tasks: ['copy:assets'],
        options: {
          spawn: false,
        }
      }
    },

    // nodemon watches for changes and restarts app
    nodemon: {
      dev: {
        script: 'server.js',
        options: {
          ext: 'js, json, html',
          ignore: ['node_modules/**', 'app/assets/**', 'public/**'],
          args: grunt.option.flags()
        }
      }
    },

    concurrent: {
        target: {
            tasks: ['watch', 'nodemon'],
            options: {
                logConcurrentOutput: true
            }
        }
    }
  });

  [
    'grunt-contrib-copy',
    'grunt-contrib-watch',
    'grunt-contrib-clean',
    'grunt-sass',
    'grunt-nodemon',
    'grunt-concurrent'
  ].forEach(function (task) {
    grunt.loadNpmTasks(task);
  });

  grunt.registerTask('generate-assets', [
    'clean',
    'copy',
    'sass'
  ]);

  grunt.registerTask('default', [
    'generate-assets',
    'concurrent:target'
  ]);

  grunt.registerTask(
    'test',
    'default',
    function () {
      grunt.log.writeln('Test that the app runs');
    }
  );

  grunt.event.on('watch', function(action, filepath, target) {

    // just copy the asset that was changed, not all of them

    if (target == "assets"){
      grunt.config('copy.assets.files.0.src', filepath.replace("app/assets/",""));
    }

  });

};
<|endoftext|>


<commit_before>// Configuration
module.exports = function(grunt) {
    grunt.initConfig({
        pkg: '<json:package.json>',

        htmlhint: {
            all: {
                options: {
                    'tagname-lowercase': true,
                    'attr-lowercase': true,
                    'doctype-first': true,
                    'tag-pair': true,
                    'spec-char-escape': true,
                    'id-unique': true,
                    'img-alt-require': true,
                    'doctype-html5': true,
                    'id-class-value': true,
                    'style-disabled': true
                },
                src: ['*.html']
            }
        },

        jshint: {
            all: ['Gruntfile.js',
                  'scripts/main.js']
        },

        favicons: {
            options: {
                'trueColor': false,
                'precomposed': true,
                'appleTouchBackgroundColor': "auto",
                'windowsTile': true,
                'coast': false,
                'tileBlackWhite': true,
                'tileColor': "auto"
            },
            deploy: {
                src: 'favicon-source.png',
                dest: 'dist/'
            }
        },

        clean: {
            deploy: ['dist']
        },

        connect: {
            livereload: {
                options: {
                    port: 9001,
                    middleware: function(connect, options) {
                        return[
                            require('connect-livereload')(),
                            connect.static(options.base),
                            connect.directory(options.base)
                        ];
                    }
                }
            }
        },

        watch: {
            options: {
                atBegin: true,
                livereload: true
            },
            icons: {
                files: 'fontello.json',
                tasks: ['fontello:build','concat:dev', 'sass:dev']
            },
            html: {
                files: '*.html',
                tasks: ['concat:dev', 'sass:dev'],
                options: {
                    nospawn: true
                }
            },
            js: {
                files: ['scripts/main.js'],
                tasks: ['concat:dev', 'sass:dev'],
                options: {
                    nospawn: true
                }
            },
            scss: {
                files: 'scss/**/*.scss',
                tasks: ['concat:dev', 'sass:dev'],
                options: {
                    nospawn: true
                }
            }
        },

        modernizr: {
            'devFile' : 'scripts/modernizr/modernizr.js',
            'outputFile' : 'dist/scripts/modernizr/modernizr.js',
            'extra' : {
                'shiv' : false,
                'printshiv' : true,
                'load' : false,
                'mq' : true,
                'cssclasses' : true
            },
            'extensibility' : {
                'addtest' : false,
                'prefixed' : false,
                'teststyles' : false,
                'testprops' : false,
                'testallprops' : false,
                'hasevents' : false,
                'prefixes' : false,
                'domprefixes' : false
            },
            'uglify' : true,
            'tests' : [],
            // parseFiles = true: crawl all *.js, *.css, *.scss files;
            // override by defining "files" array
            'parseFiles' : true,
            'files' : ['scss/**/*.scss',
                       'scripts/magnific-popup/dist/jquery.magnific-popup.js',
                       'scripts/magnific-popup/src/css/main.scss',
                       'scripts/jquery-cycle2/*.js',
                       'scripts/jquery-accessible-tabs/js/jquery.syncheight.js',
                       'scripts/jquery-accessible-tabs/js/jquery.tabs.js',
                       'scripts/gmaps/gmaps.js',
                       'scripts/*.js'],
            'matchCommunityTests' : false,
            'customTests' : [],
            'excludeFiles' : ['Gruntfile.js', '*.json']
        },

        concat: {
            dev: {
                src: ['scripts/helpers/log.js',
                      'scripts/accessifyhtml5-amd/accessifyhtml5.js',
                      'scripts/magnific-popup/dist/jquery.magnific-popup.js',
                      'scripts/jquery-cycle2/jquery.cycle2.core.js',
                      'scripts/jquery-cycle2/jquery.cycle2.autoheight.js',
                      'scripts/jquery-cycle2/jquery.cycle2.caption.js',
                      'scripts/jquery-cycle2/jquery.cycle2.command.js',
                      'scripts/jquery-cycle2/jquery.cycle2.hash.js',
                      'scripts/jquery-cycle2/jquery.cycle2.loader.js',
                      'scripts/jquery-cycle2/jquery.cycle2.pager.js',
                      'scripts/jquery-cycle2/jquery.cycle2.prevnext.js',
                      'scripts/jquery-cycle2/jquery.cycle2.progressive.js',
                      'scripts/jquery-cycle2/jquery.cycle2.tmpl.js',
                      'scripts/jquery-accessible-tabs/js/jquery.syncheight.js',
                      'scripts/jquery-accessible-tabs/js/jquery.tabs.js',
                      'scripts/gmaps/gmaps.js',
                      'scripts/main.js'],
                dest: 'scripts/master.js'
            },
            deploy: {
                src: ['scripts/accessifyhtml5-amd/accessifyhtml5.js',
                      'scripts/magnific-popup/dist/jquery.magnific-popup.js',
                      'scripts/jquery-cycle2/jquery.cycle2.core.js',
                      'scripts/jquery-cycle2/jquery.cycle2.autoheight.js',
                      'scripts/jquery-cycle2/jquery.cycle2.caption.js',
                      'scripts/jquery-cycle2/jquery.cycle2.command.js',
                      'scripts/jquery-cycle2/jquery.cycle2.hash.js',
                      'scripts/jquery-cycle2/jquery.cycle2.loader.js',
                      'scripts/jquery-cycle2/jquery.cycle2.pager.js',
                      'scripts/jquery-cycle2/jquery.cycle2.prevnext.js',
                      'scripts/jquery-cycle2/jquery.cycle2.progressive.js',
                      'scripts/jquery-cycle2/jquery.cycle2.tmpl.js',
                      'scripts/jquery-accessible-tabs/js/jquery.syncheight.js',
                      'scripts/jquery-accessible-tabs/js/jquery.tabs.js',
                      'scripts/gmaps/gmaps.js',
                      'scripts/main.js'],
                dest: 'scripts/master.js'
            }
        },

        uglify: {
            deploy: {
                src: 'scripts/master.js',
                dest: 'dist/scripts/master.js'
            }
        },

        sass: {
            dev: {
                options: {
                    sourcemap: false,
                    style: 'nested',
                    precision: 5
                },
                files: [{
                    expand: true,
                    cwd: 'scss',
                    src: ['*.scss'],
                    dest: 'styles',
                    ext: '.css'
                }]
            },
            deploy: {
                options: {
                    sourcemap: false,
                    style: 'compressed',
                    precision: 5
                },
                files: [{
                    expand: true,
                    cwd: 'scss',
                    src: ['*.scss'],
                    dest: 'dist/styles',
                    ext: '.css'
                }]
            }
        },

        imagemin: {
            deploy: {
                options: {
                    optimizationLevel: 1,
                    progressive: false
                },
                files: [
                    {
                        expand: true,
                        cwd: '.',
                        src: ['img/**/*.png', 'img/**/*.jpg'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        copy: {
            deploy: {
                files: [
                    {
                        src: ['.htaccess',
                              'robots.txt',
                              'scripts/jquery/jquery.min.js',
                              'scripts/helpers/boxsizing.htc',
                              'font/*',
                              '*.html'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        hashres: {
            options: {
                encoding: 'utf-8',
                fileNameFormat: '${hash}.${ext}',
                renameFiles: true
            },
            deploy: {
                src: ['dist/styles/master.css',
                      'dist/styles/oldie.css',
                      'dist/scripts/master.js'],
                dest: 'dist/*.html',

            }
        },

        // To use this for target-based includes, e.g. to include Piwik snippet:
        // <!--(if target deploy)><!(endif)-->
        // → github.com/changer/grunt-targethtml
        targethtml: {
            deploy: {
                files: [{
                    expand: true,
                    src: ['*.html'],
                    dest: 'dist/'
                }],
            }
        },

        fontello: {
            options: {
                config: 'fontello.json',
                zip: 'scripts/',
                fonts: 'font/',
                styles: 'scss/fontello/',
                sass: true,
                force: true
            },
            build: {
                config: 'fontello.json',
                fonts: 'font/',
                styles: 'scss/fontello/'
            }
        }
    });
    // Load required tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-favicons');
    grunt.loadNpmTasks('grunt-fontello');
    grunt.loadNpmTasks('grunt-hashres');
    grunt.loadNpmTasks('grunt-htmlhint');
    grunt.loadNpmTasks('grunt-modernizr');
    grunt.loadNpmTasks('grunt-targethtml');
    // Default
    grunt.registerTask('default', ['connect', 'watch']);
    // Testing
    grunt.registerTask('test', ['htmlhint', 'jshint']);
    // Deployment
    grunt.registerTask('deploy', ['clean:deploy', 'fontello:build', 'copy:deploy', 'concat:deploy', 'sass:deploy', 'uglify', 'imagemin:deploy', 'favicons:deploy', 'modernizr', 'targethtml:deploy', 'hashres:deploy']);
};
<commit_msg>Simplified watch task for better performance.<commit_after>// Configuration
module.exports = function(grunt) {
    grunt.initConfig({
        pkg: '<json:package.json>',

        htmlhint: {
            all: {
                options: {
                    'tagname-lowercase': true,
                    'attr-lowercase': true,
                    'doctype-first': true,
                    'tag-pair': true,
                    'spec-char-escape': true,
                    'id-unique': true,
                    'img-alt-require': true,
                    'doctype-html5': true,
                    'id-class-value': true,
                    'style-disabled': true
                },
                src: ['*.html']
            }
        },

        jshint: {
            all: ['Gruntfile.js',
                  'scripts/main.js']
        },

        favicons: {
            options: {
                'trueColor': false,
                'precomposed': true,
                'appleTouchBackgroundColor': "auto",
                'windowsTile': true,
                'coast': false,
                'tileBlackWhite': true,
                'tileColor': "auto"
            },
            deploy: {
                src: 'favicon-source.png',
                dest: 'dist/'
            }
        },

        clean: {
            deploy: ['dist']
        },

        connect: {
            livereload: {
                options: {
                    port: 9001,
                    middleware: function(connect, options) {
                        return[
                            require('connect-livereload')(),
                            connect.static(options.base),
                            connect.directory(options.base)
                        ];
                    }
                }
            }
        },

        watch: {
            options: {
                atBegin: true,
                livereload: true
            },
            icons: {
                files: 'fontello.json',
                tasks: ['fontello:build'],
                options: {
                    spawn: false
                }
            },
            html: {
                files: '*.html',
                tasks: [],
                options: {
                    spawn: false
                }
            },
            js: {
                files: ['scripts/main.js'],
                tasks: ['concat:dev'],
                options: {
                    spawn: false
                }
            },
            scss: {
                files: 'scss/**/*.scss',
                tasks: ['sass:dev'],
                options: {
                    spawn: false
                }
            }
        },

        modernizr: {
            'devFile' : 'scripts/modernizr/modernizr.js',
            'outputFile' : 'dist/scripts/modernizr/modernizr.js',
            'extra' : {
                'shiv' : false,
                'printshiv' : true,
                'load' : false,
                'mq' : true,
                'cssclasses' : true
            },
            'extensibility' : {
                'addtest' : false,
                'prefixed' : false,
                'teststyles' : false,
                'testprops' : false,
                'testallprops' : false,
                'hasevents' : false,
                'prefixes' : false,
                'domprefixes' : false
            },
            'uglify' : true,
            'tests' : [],
            // parseFiles = true: crawl all *.js, *.css, *.scss files;
            // override by defining "files" array
            'parseFiles' : true,
            'files' : ['scss/**/*.scss',
                       'scripts/magnific-popup/dist/jquery.magnific-popup.js',
                       'scripts/magnific-popup/src/css/main.scss',
                       'scripts/jquery-cycle2/*.js',
                       'scripts/jquery-accessible-tabs/js/jquery.syncheight.js',
                       'scripts/jquery-accessible-tabs/js/jquery.tabs.js',
                       'scripts/gmaps/gmaps.js',
                       'scripts/*.js'],
            'matchCommunityTests' : false,
            'customTests' : [],
            'excludeFiles' : ['Gruntfile.js', '*.json']
        },

        concat: {
            dev: {
                src: ['scripts/helpers/log.js',
                      'scripts/accessifyhtml5-amd/accessifyhtml5.js',
                      'scripts/magnific-popup/dist/jquery.magnific-popup.js',
                      'scripts/jquery-cycle2/jquery.cycle2.core.js',
                      'scripts/jquery-cycle2/jquery.cycle2.autoheight.js',
                      'scripts/jquery-cycle2/jquery.cycle2.caption.js',
                      'scripts/jquery-cycle2/jquery.cycle2.command.js',
                      'scripts/jquery-cycle2/jquery.cycle2.hash.js',
                      'scripts/jquery-cycle2/jquery.cycle2.loader.js',
                      'scripts/jquery-cycle2/jquery.cycle2.pager.js',
                      'scripts/jquery-cycle2/jquery.cycle2.prevnext.js',
                      'scripts/jquery-cycle2/jquery.cycle2.progressive.js',
                      'scripts/jquery-cycle2/jquery.cycle2.tmpl.js',
                      'scripts/jquery-accessible-tabs/js/jquery.syncheight.js',
                      'scripts/jquery-accessible-tabs/js/jquery.tabs.js',
                      'scripts/gmaps/gmaps.js',
                      'scripts/main.js'],
                dest: 'scripts/master.js'
            },
            deploy: {
                src: ['scripts/accessifyhtml5-amd/accessifyhtml5.js',
                      'scripts/magnific-popup/dist/jquery.magnific-popup.js',
                      'scripts/jquery-cycle2/jquery.cycle2.core.js',
                      'scripts/jquery-cycle2/jquery.cycle2.autoheight.js',
                      'scripts/jquery-cycle2/jquery.cycle2.caption.js',
                      'scripts/jquery-cycle2/jquery.cycle2.command.js',
                      'scripts/jquery-cycle2/jquery.cycle2.hash.js',
                      'scripts/jquery-cycle2/jquery.cycle2.loader.js',
                      'scripts/jquery-cycle2/jquery.cycle2.pager.js',
                      'scripts/jquery-cycle2/jquery.cycle2.prevnext.js',
                      'scripts/jquery-cycle2/jquery.cycle2.progressive.js',
                      'scripts/jquery-cycle2/jquery.cycle2.tmpl.js',
                      'scripts/jquery-accessible-tabs/js/jquery.syncheight.js',
                      'scripts/jquery-accessible-tabs/js/jquery.tabs.js',
                      'scripts/gmaps/gmaps.js',
                      'scripts/main.js'],
                dest: 'scripts/master.js'
            }
        },

        uglify: {
            deploy: {
                src: 'scripts/master.js',
                dest: 'dist/scripts/master.js'
            }
        },

        sass: {
            dev: {
                options: {
                    sourcemap: false,
                    style: 'nested',
                    precision: 5
                },
                files: [{
                    expand: true,
                    cwd: 'scss',
                    src: ['*.scss'],
                    dest: 'styles',
                    ext: '.css'
                }]
            },
            deploy: {
                options: {
                    sourcemap: false,
                    style: 'compressed',
                    precision: 5
                },
                files: [{
                    expand: true,
                    cwd: 'scss',
                    src: ['*.scss'],
                    dest: 'dist/styles',
                    ext: '.css'
                }]
            }
        },

        imagemin: {
            deploy: {
                options: {
                    optimizationLevel: 1,
                    progressive: false
                },
                files: [
                    {
                        expand: true,
                        cwd: '.',
                        src: ['img/**/*.png', 'img/**/*.jpg'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        copy: {
            deploy: {
                files: [
                    {
                        src: ['.htaccess',
                              'robots.txt',
                              'scripts/jquery/jquery.min.js',
                              'scripts/helpers/boxsizing.htc',
                              'font/*',
                              '*.html'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        hashres: {
            options: {
                encoding: 'utf-8',
                fileNameFormat: '${hash}.${ext}',
                renameFiles: true
            },
            deploy: {
                src: ['dist/styles/master.css',
                      'dist/styles/oldie.css',
                      'dist/scripts/master.js'],
                dest: 'dist/*.html',

            }
        },

        // To use this for target-based includes, e.g. to include Piwik snippet:
        // <!--(if target deploy)><!(endif)-->
        // → github.com/changer/grunt-targethtml
        targethtml: {
            deploy: {
                files: [{
                    expand: true,
                    src: ['*.html'],
                    dest: 'dist/'
                }],
            }
        },

        fontello: {
            options: {
                config: 'fontello.json',
                zip: 'scripts/',
                fonts: 'font/',
                styles: 'scss/fontello/',
                sass: true,
                force: true
            },
            build: {
                config: 'fontello.json',
                fonts: 'font/',
                styles: 'scss/fontello/'
            }
        }
    });
    // Load required tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-favicons');
    grunt.loadNpmTasks('grunt-fontello');
    grunt.loadNpmTasks('grunt-hashres');
    grunt.loadNpmTasks('grunt-htmlhint');
    grunt.loadNpmTasks('grunt-modernizr');
    grunt.loadNpmTasks('grunt-targethtml');
    // Default
    grunt.registerTask('default', ['connect', 'watch']);
    // Testing
    grunt.registerTask('test', ['htmlhint', 'jshint']);
    // Deployment
    grunt.registerTask('deploy', ['clean:deploy', 'fontello:build', 'copy:deploy', 'concat:deploy', 'sass:deploy', 'uglify', 'imagemin:deploy', 'favicons:deploy', 'modernizr', 'targethtml:deploy', 'hashres:deploy']);
};
<|endoftext|>