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

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

module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);
  require('time-grunt')(grunt);

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

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

  grunt.initConfig({
    yeoman: yeomanConfig,
    watch: {
      coffee: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
        tasks: ['coffee:dist']
      },
      coffeeTest: {
        files: ['test/spec/{,*/}*.coffee'],
        tasks: ['coffee:test']
      },
      compass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['copy:styles', 'autoprefixer']
      },
      livereload: {
        options: {
          livereload: LIVERELOAD_PORT
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },
    autoprefixer: {
      options: ['last 1 version'],
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, '.tmp'),
              mountFolder(connect, yeomanConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, '.tmp'),
              mountFolder(connect, 'test')
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, yeomanConfig.dist)
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ]
    },
    coffee: {
      options: {
        sourceMap: true,
        sourceRoot: ''
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts',
          src: '{,*/}*.coffee',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/images/generated',
        imagesDir: '<%= yeoman.app %>/images',
        javascriptsDir: '<%= yeoman.app %>/scripts',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: '<%= yeoman.app %>/bower_components',
        httpImagesPath: '/images',
        httpGeneratedImagesPath: '/images/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false
      },
      dist: {},
      server: {
        options: {
          debugInfo: true
        }
      }
    },
    // not used since Uglify task does concat,
    // but still available if needed
    /*concat: {
      dist: {}
    },*/
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        dirs: ['<%= yeoman.dist %>']
      }
    },
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    cssmin: {
      // By default, your `index.html` <!-- Usemin Block --> will take care of
      // minification. This option is pre-configured if you do not wish to use
      // Usemin blocks.
      // dist: {
      //   files: {
      //     '<%= yeoman.dist %>/styles/main.css': [
      //       '.tmp/styles/{,*/}*.css',
      //       '<%= yeoman.app %>/styles/{,*/}*.css'
      //     ]
      //   }
      // }
    },
    htmlmin: {
      dist: {
        options: {
          /*removeCommentsFromCDATA: true,
          // https://github.com/yeoman/grunt-usemin/issues/44
          //collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: true,
          useShortDoctype: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true*/
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>',
          src: ['*.html', 'views/**/*.*', 'template/**/*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    // Put files not handled in other tasks here
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'images/{,*/}*.{gif,webp}',
            'styles/fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: [
            'generated/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles',
        src: '{,*/}*.css'
      },
      i18n: {
        expand: true,
        cwd: '<%= yeoman.app %>/bower_components/angular-i18n',
        dest: '.tmp/i18n/angular',
        src: '*.js'
      }
    },
    concurrent: {
      server: [
        'coffee:dist',
        'compass:server',
        'copy:styles',
        'copy:i18n'
      ],
      test: [
        'coffee',
        'compass',
        'copy:styles'
      ],
      dist: [
        'coffee',
        'compass:dist',
        'copy:styles',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/scripts',
          src: '*.js',
          dest: '<%= yeoman.dist %>/scripts'
        }]
      }
    },
    uglify: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': [
            '<%= yeoman.dist %>/scripts/scripts.js'
          ]
        }
      }
    }
  });

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

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

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

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

  grunt.registerTask('default', [
    'jshint',
    'test',
    'build'
  ]);
};
<commit_msg>- Formatted to comply JSHint - Fixed livereload for all js files<commit_after>// Generated on 2013-09-19 using generator-angular 0.4.0
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
    port: LIVERELOAD_PORT
});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

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

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

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

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

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            coffee: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.coffee'],
                tasks: ['coffee:test']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/**/*.js',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        autoprefixer: {
            options: ['last 1 version'],
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app)];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [mountFolder(connect, yeomanConfig.dist)];
                    }
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/{,*/}*.js'
            ]
        },
        coffee: {
            options: {
                sourceMap: true,
                sourceRoot: ''
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/scripts',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/scripts',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: 'test/spec',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/spec',
                    ext: '.js'
                }]
            }
        },
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false
            },
            dist: {},
            server: {
                options: {
                    debugInfo: true
                }
            }
        },
        // not used since Uglify task does concat,
        // but still available if needed
        /*concat: {
      dist: {}
    },*/
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            // By default, your `index.html` <!-- Usemin Block --> will take care of
            // minification. This option is pre-configured if you do not wish to use
            // Usemin blocks.
            // dist: {
            //   files: {
            //     '<%= yeoman.dist %>/styles/main.css': [
            //       '.tmp/styles/{,*/}*.css',
            //       '<%= yeoman.app %>/styles/{,*/}*.css'
            //     ]
            //   }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
          // https://github.com/yeoman/grunt-usemin/issues/44
          //collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: true,
          useShortDoctype: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: ['*.html', 'views/**/*.*', 'template/**/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'bower_components/**/*',
                        'images/{,*/}*.{gif,webp}',
                        'styles/fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*'
                    ]
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles',
                src: '{,*/}*.css'
            },
            i18n: {
                expand: true,
                cwd: '<%= yeoman.app %>/bower_components/angular-i18n',
                dest: '.tmp/i18n/angular',
                src: '*.js'
            }
        },
        concurrent: {
            server: [
                'coffee:dist',
                'compass:server',
                'copy:styles',
                'copy:i18n'
            ],
            test: [
                'coffee',
                'compass',
                'copy:styles'
            ],
            dist: [
                'coffee',
                'compass:dist',
                'copy:styles',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        ngmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>/scripts',
                    src: '*.js',
                    dest: '<%= yeoman.dist %>/scripts'
                }]
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/scripts/scripts.js': [
                        '<%= yeoman.dist %>/scripts/scripts.js'
                    ]
                }
            }
        }
    });

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

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

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

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

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


<commit_before>module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt, {
    pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
  });

  grunt.initConfig({
    // Globals
    dir: grunt.file.readJSON('./conf/grunt/globals/dir.json'),
    pkg: grunt.file.readJSON('package.json'),
    // Tasks
    clean: require('./conf/grunt/tasks/clean.js'),
    jasmine: require('./conf/grunt/tasks/jasmine.js'),
    uglify: require('./conf/grunt/tasks/uglify.js')
  });

  grunt.registerTask('module-test', 'jasmine:test');
  grunt.registerTask('module-distribute', [
    'clean:dist',
    'uglify:dist'
  ]);
};
<commit_msg>Renamed "module-*" into "code-*"<commit_after>module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt, {
    pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
  });

  grunt.initConfig({
    // Globals
    dir: grunt.file.readJSON('./conf/grunt/globals/dir.json'),
    pkg: grunt.file.readJSON('package.json'),
    // Tasks
    clean: require('./conf/grunt/tasks/clean.js'),
    jasmine: require('./conf/grunt/tasks/jasmine.js'),
    uglify: require('./conf/grunt/tasks/uglify.js'),
  });

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


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

    jshint: {
      files: [
        'app/**/*.js',
        'admin/**/*.js',
        'test/**/*.js',
        'shared/**/*.js',
        'server/**/*.js'
      ],
      options: {
        globals: {
          window: true,
          document: true,
          navigator: true,
          console: true,
          module: true,
          require: true,
          FastClick: true,
          $: true,
          Backbone: true,
          Parse: true,
          Handlebars: true,
          _: true,
          google: true,
          parseAppKey: true,
          parseJSKey: true
        },
        undef: true,
        debug: true,
        '-W030': true
      }
    },

    // A simple Grunt invoker for mocha tests
    simplemocha: {
      options: {
        timeout: 3000,
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'list'
      },

      all: {
        src: 'test/**/*.js'
      }
    },

    // run the 'default' task when any watched files change
    watch: {
      files: [
        'Gruntfile.js',
        'app/**/*',
        'admin/**/*',
        'shared/**/*',
        'server/**/*',
        'vendor/**/*',
        'test/**/*'
      ],
      tasks: ['default']
    },

    sass: {
      // generate app-specific css file
      app: {
        src: 'app/css/app.scss',
        dest: 'tmp/linksf.css'
      },

      admin: {
        src: 'admin/css/admin.scss',
        dest: 'tmp/linksf_admin.css'
      }
    },

    // Browserify
    browserify: {
      options: {
        // We want `.hbs` files to be `require`able. We use the hbsfy transform
        // to precompile Handlebars templates and let us require the compiled
        // JavaScript functions.
        transform: ['hbsfy']
      },
      app: {
        // The entry point where Browserify will begin searching the AST for `require` calls
        src: 'app/js/app.js',

        // The built file
        dest: 'tmp/app.js',

        options: {
          // We want alias mappings because we'd rather
          // `require('views/index_view')` than `require('./views/index_view.js')`
          //
          // There is a tradeoff for convenient here - all aliased files are exported
          // into the built app.js file, even if they're never explicitly
          // `require`d from the entry point tree.
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'app/js/lib',            src: '*.js',  dest: 'lib' },
            { cwd: 'app/js/models',         src: '*.js',  dest: 'models' },
            { cwd: 'app/js/collections',    src: '*.js',  dest: 'collections' },
            { cwd: 'app/js/routers',        src: '*.js',  dest: 'routers' },
            { cwd: 'app/js/templates',      src: '*.hbs', dest: 'templates' },
            { cwd: 'app/js/views',          src: '*.js',  dest: 'views' }
          ]
        }
      },
      // See browserify:app above
      admin: {
        src: 'admin/js/admin.js',
        dest: 'tmp/admin.js',
        options: {
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'admin/js/lib',          src: '*.js',  dest: 'lib' },
            { cwd: 'admin/js/models',       src: '*.js',  dest: 'models' },
            { cwd: 'admin/js/collections',  src: '*.js',  dest: 'collections' },
            { cwd: 'admin/js/routers',      src: '*.js',  dest: 'routers' },
            { cwd: 'admin/js/templates',    src: '*.hbs', dest: 'templates' },
            { cwd: 'admin/js/views',        src: '*.js',  dest: 'views' }
          ]
        }
      }
    },

    // Minify css files
    cssmin: {
      app: {
        src: 'tmp/linksf.css',
        dest: 'tmp/linksf.css'
      },
      admin: {
        src: 'tmp/linksf_admin.css',
        dest: 'tmp/linksf_admin.css'
      },
    },

    // Concatenate files together.
    concat: {
      // Not a target, just a variable that we can interpolate in elsewhere.
      shared_js: [
        'vendor/js/jquery-2.0.3.js',
        'vendor/js/jquery.serialize-object.js',
        'vendor/js/bootstrap-button.js',
        'vendor/js/underscore.js',
        'vendor/js/backbone-1.0.0.js',
        'vendor/js/parse-1.2.12.js'
      ],

      shared_js_minified: [
        'vendor/js/jquery-2.0.3.min.js',
        'vendor/js/jquery.serialize-object.min.js',
        'vendor/js/bootstrap-button.min.js',
        'vendor/js/underscore.min.js',
        'vendor/js/backbone-1.0.0.min.js',
        'vendor/js/parse-1.2.12.min.js'
      ],

      // App also uses the vendored fastclick library
      app: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/fastclick.js',
          'tmp/app.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Concat minified files
      app_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/fastclick.min.js',
          'tmp/app.min.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Admin uses backbone filters for authentication and autosize for text entry
      admin: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/backbone_filters.js',
          'vendor/js/jquery.autosize.js',
          'vendor/js/bootstrap.js',
          'tmp/admin.js'
        ],
        dest: 'tmp/linksf_admin.js'
      },

      admin_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/backbone_filters.min.js',
          'vendor/js/jquery.autosize.min.js',
          'vendor/js/bootstrap.min.js',
          'tmp/admin.min.js'
        ],
        dest: 'tmp/linksf_admin.js'
      }
    },

    uglify: {
      options: {
        mangle: false,
        preserveComments: false,
        report: 'min'
      },

      vendor: {
        files: {
          // These libraries are not distributed with minified versions, so we
          // minify them ourselves.
          'vendor/js/jquery.serialize-object.min.js': 'vendor/js/jquery.serialize-object.js',
          'vendor/js/backbone_filters.min.js': 'vendor/js/backbone_filters.js',
          'vendor/js/bootstrap-button.min.js': 'vendor/js/bootstrap-button.js'
        }
      },
      app: {files: {'tmp/app.min.js': 'tmp/app.js'}},
      admin: {files: {'tmp/admin.min.js': 'tmp/admin.js'}}
    },

    clean: {
      build: {
        src: 'build/*',
        filter: function(filepath) { return filepath !== 'build/.gitkeep'; }
      }
    },

    cachebuster: {
      dist: {
        files: {
          src: [
            'tmp/linksf.js',
            'tmp/linksf.css',
            'tmp/linksf_admin.js',
            'tmp/linksf_admin.css'
          ],
        },
        options: {
          complete: function(hashes) {
            // ugly but the only way to tag each file with a key
            var keyMap = {
                'tmp/linksf.js': 'linksf_js',
                'tmp/linksf.css': 'linksf_css',
                'tmp/linksf_admin.js': 'linksf_admin_js',
                'tmp/linksf_admin.css': 'linksf_admin_css'
               },
               context = {},
               context.parseAppKey = process.env.PARSE_APP_KEY || 'Y213cb9EqDqUka0d56iQ1ZEyCeqsi4TMIh5zGTtY';
               context.parseJSKey  = process.env.PARSE_JS_KEY || 'CJrY4twgkR8KluQEtgMrbtciyk9rIFkILLxCRZGq';
               Handlebars = require('handlebars'),
               template,
               output;

            Object.keys(hashes).forEach(function(key) {
              var matches = key.match(/^tmp\/(.*)(\..*)$/),
                  outputFile = 'build/' + matches[1] + '-' + hashes[key] + matches[2];

              grunt.file.copy(key, outputFile);
              context[keyMap[key]] = outputFile;
            });

            template = Handlebars.compile(grunt.file.read('app/index.html'));
            output = template(context);
            grunt.file.write('index.html', output);

            template = Handlebars.compile(grunt.file.read('admin/admin.html'));
            output = template(context);
            grunt.file.write('admin.html', output);
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-cachebuster');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');

  grunt.registerTask('build:development', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'browserify',
    'concat:app',
    'concat:admin',
    'cachebuster'
  ]);

  grunt.registerTask('build:production', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'cssmin',
    'browserify',
    'uglify',
    'concat:app_min',
    'concat:admin_min',
    'cachebuster'
  ]);

  grunt.registerTask('default', [
    'build:development'
  ]);

  grunt.registerTask('release', [
    'build:production'
  ]);
};
<commit_msg>fix gruntfile context setup<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    jshint: {
      files: [
        'app/**/*.js',
        'admin/**/*.js',
        'test/**/*.js',
        'shared/**/*.js',
        'server/**/*.js'
      ],
      options: {
        globals: {
          window: true,
          document: true,
          navigator: true,
          console: true,
          module: true,
          require: true,
          FastClick: true,
          $: true,
          Backbone: true,
          Parse: true,
          Handlebars: true,
          _: true,
          google: true,
          parseAppKey: true,
          parseJSKey: true
        },
        undef: true,
        debug: true,
        '-W030': true
      }
    },

    // A simple Grunt invoker for mocha tests
    simplemocha: {
      options: {
        timeout: 3000,
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'list'
      },

      all: {
        src: 'test/**/*.js'
      }
    },

    // run the 'default' task when any watched files change
    watch: {
      files: [
        'Gruntfile.js',
        'app/**/*',
        'admin/**/*',
        'shared/**/*',
        'server/**/*',
        'vendor/**/*',
        'test/**/*'
      ],
      tasks: ['default']
    },

    sass: {
      // generate app-specific css file
      app: {
        src: 'app/css/app.scss',
        dest: 'tmp/linksf.css'
      },

      admin: {
        src: 'admin/css/admin.scss',
        dest: 'tmp/linksf_admin.css'
      }
    },

    // Browserify
    browserify: {
      options: {
        // We want `.hbs` files to be `require`able. We use the hbsfy transform
        // to precompile Handlebars templates and let us require the compiled
        // JavaScript functions.
        transform: ['hbsfy']
      },
      app: {
        // The entry point where Browserify will begin searching the AST for `require` calls
        src: 'app/js/app.js',

        // The built file
        dest: 'tmp/app.js',

        options: {
          // We want alias mappings because we'd rather
          // `require('views/index_view')` than `require('./views/index_view.js')`
          //
          // There is a tradeoff for convenient here - all aliased files are exported
          // into the built app.js file, even if they're never explicitly
          // `require`d from the entry point tree.
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'app/js/lib',            src: '*.js',  dest: 'lib' },
            { cwd: 'app/js/models',         src: '*.js',  dest: 'models' },
            { cwd: 'app/js/collections',    src: '*.js',  dest: 'collections' },
            { cwd: 'app/js/routers',        src: '*.js',  dest: 'routers' },
            { cwd: 'app/js/templates',      src: '*.hbs', dest: 'templates' },
            { cwd: 'app/js/views',          src: '*.js',  dest: 'views' }
          ]
        }
      },
      // See browserify:app above
      admin: {
        src: 'admin/js/admin.js',
        dest: 'tmp/admin.js',
        options: {
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'admin/js/lib',          src: '*.js',  dest: 'lib' },
            { cwd: 'admin/js/models',       src: '*.js',  dest: 'models' },
            { cwd: 'admin/js/collections',  src: '*.js',  dest: 'collections' },
            { cwd: 'admin/js/routers',      src: '*.js',  dest: 'routers' },
            { cwd: 'admin/js/templates',    src: '*.hbs', dest: 'templates' },
            { cwd: 'admin/js/views',        src: '*.js',  dest: 'views' }
          ]
        }
      }
    },

    // Minify css files
    cssmin: {
      app: {
        src: 'tmp/linksf.css',
        dest: 'tmp/linksf.css'
      },
      admin: {
        src: 'tmp/linksf_admin.css',
        dest: 'tmp/linksf_admin.css'
      },
    },

    // Concatenate files together.
    concat: {
      // Not a target, just a variable that we can interpolate in elsewhere.
      shared_js: [
        'vendor/js/jquery-2.0.3.js',
        'vendor/js/jquery.serialize-object.js',
        'vendor/js/bootstrap-button.js',
        'vendor/js/underscore.js',
        'vendor/js/backbone-1.0.0.js',
        'vendor/js/parse-1.2.12.js'
      ],

      shared_js_minified: [
        'vendor/js/jquery-2.0.3.min.js',
        'vendor/js/jquery.serialize-object.min.js',
        'vendor/js/bootstrap-button.min.js',
        'vendor/js/underscore.min.js',
        'vendor/js/backbone-1.0.0.min.js',
        'vendor/js/parse-1.2.12.min.js'
      ],

      // App also uses the vendored fastclick library
      app: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/fastclick.js',
          'tmp/app.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Concat minified files
      app_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/fastclick.min.js',
          'tmp/app.min.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Admin uses backbone filters for authentication and autosize for text entry
      admin: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/backbone_filters.js',
          'vendor/js/jquery.autosize.js',
          'vendor/js/bootstrap.js',
          'tmp/admin.js'
        ],
        dest: 'tmp/linksf_admin.js'
      },

      admin_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/backbone_filters.min.js',
          'vendor/js/jquery.autosize.min.js',
          'vendor/js/bootstrap.min.js',
          'tmp/admin.min.js'
        ],
        dest: 'tmp/linksf_admin.js'
      }
    },

    uglify: {
      options: {
        mangle: false,
        preserveComments: false,
        report: 'min'
      },

      vendor: {
        files: {
          // These libraries are not distributed with minified versions, so we
          // minify them ourselves.
          'vendor/js/jquery.serialize-object.min.js': 'vendor/js/jquery.serialize-object.js',
          'vendor/js/backbone_filters.min.js': 'vendor/js/backbone_filters.js',
          'vendor/js/bootstrap-button.min.js': 'vendor/js/bootstrap-button.js'
        }
      },
      app: {files: {'tmp/app.min.js': 'tmp/app.js'}},
      admin: {files: {'tmp/admin.min.js': 'tmp/admin.js'}}
    },

    clean: {
      build: {
        src: 'build/*',
        filter: function(filepath) { return filepath !== 'build/.gitkeep'; }
      }
    },

    cachebuster: {
      dist: {
        files: {
          src: [
            'tmp/linksf.js',
            'tmp/linksf.css',
            'tmp/linksf_admin.js',
            'tmp/linksf_admin.css'
          ],
        },
        options: {
          complete: function(hashes) {
            // ugly but the only way to tag each file with a key
            var keyMap = {
                'tmp/linksf.js': 'linksf_js',
                'tmp/linksf.css': 'linksf_css',
                'tmp/linksf_admin.js': 'linksf_admin_js',
                'tmp/linksf_admin.css': 'linksf_admin_css'
               },
               context = {},
               Handlebars = require('handlebars'),
               template,
               output;

            context.parseAppKey = process.env.PARSE_APP_KEY || 'Y213cb9EqDqUka0d56iQ1ZEyCeqsi4TMIh5zGTtY';
            context.parseJSKey  = process.env.PARSE_JS_KEY || 'CJrY4twgkR8KluQEtgMrbtciyk9rIFkILLxCRZGq';

            Object.keys(hashes).forEach(function(key) {
              var matches = key.match(/^tmp\/(.*)(\..*)$/),
                  outputFile = 'build/' + matches[1] + '-' + hashes[key] + matches[2];

              grunt.file.copy(key, outputFile);
              context[keyMap[key]] = outputFile;
            });

            template = Handlebars.compile(grunt.file.read('app/index.html'));
            output = template(context);
            grunt.file.write('index.html', output);

            template = Handlebars.compile(grunt.file.read('admin/admin.html'));
            output = template(context);
            grunt.file.write('admin.html', output);
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-cachebuster');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');

  grunt.registerTask('build:development', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'browserify',
    'concat:app',
    'concat:admin',
    'cachebuster'
  ]);

  grunt.registerTask('build:production', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'cssmin',
    'browserify',
    'uglify',
    'concat:app_min',
    'concat:admin_min',
    'cachebuster'
  ]);

  grunt.registerTask('default', [
    'build:development'
  ]);

  grunt.registerTask('release', [
    'build:production'
  ]);
};
<|endoftext|>


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

	var path = require('path')

		// Merge configuration data
		,cfg = require('./app_modules/configure')
			.merge('_config/', [
				 'default'
				,'project'
				,'secret'
				,'local'
			]).get()

		,modulesPattern = path.join(cfg.paths.modulesBaseDir, cfg.moduleDirName.replace('{{name}}', '*'))
		,buildBaseDir = path.join(cfg.paths.staticBaseDir, cfg.static.build.baseDirName); // build.baseDirName may be empty
	;

	grunt.initConfig({

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

		,staticUriPrefix:   cfg.staticUriPrefix

		// Sources base paths

		,tcInline:          cfg.paths.inline
		,tcBase:            cfg.paths.base
		,tcModules:         modulesPattern
		,tcApplication:     cfg.paths.application
		,staticDir:         cfg.paths.staticBaseDir

		// Output destinations

		,buildBaseDir: buildBaseDir
		,tmp:               '<%=buildBaseDir%>/tmp'
		,destJs:            '<%=buildBaseDir%>'
		,destCss:           '<%=buildBaseDir%>'
		,destSpritesCss:    '<%=tcBase%>/css/sprites' // technically this should go in tmp, but we want the generated classes in our base css for easy lookup.
		,destSpritesImg:    '<%=buildBaseDir%>'

		// Sources patterns

		,sources: {
			inline_css: [
				 '<%=tcInline%>/css/lib/*.css'
				,'<%=tcInline%>/css/*.less'
			]
			,external_css: [
				 '<%=tcBase%>/css/sprites/*.less'
				,'<%=tcBase%>/css/lib/*.css'
				,'<%=tcBase%>/css/elements/*.less'
				,'<%=tcModules%>/*.less'
				,'<%=tcModules%>/skin/*.less'
				,'<%=tcApplication%>/css/*.less'
			]
			,inline_js: [
				 '<%=tcInline%>/js/lib/*.js'
				,'<%=tcInline%>/js/*.js'
			]
			,external_js: [
				 '<%=tcBase%>/js/lib/*.js'
				,'<%=tcModules%>/*.js'
				,'<%=tcModules%>/skin/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,module_test_js: [
				 '<%=staticDir%>/test/*.js'
				,'<%=tcModules%>/test/*.js'
			]
			,jshint_inline: [
				 '<%=tcInline%>/js/*.js'
			]
			,jshint_external: [
				 '<%=tcModules%>/*.js'
				,'<%=tcModules%>/skin/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,jshint_module_test: [
				 //'<%=staticDir%>/_static/test/*.js'
				//,'<%=tcModules%>/test/*.js'
			]
			,sprites: [
				'<%=tcBase%>/css/sprites/'
				//,'<%=tcModules%>/sprites/'
			]
		}

		//////////////////////////////////////////////////////////////

		,glue: {
			icons: {
				src: '<%=sources.sprites%>'
				//,dest: '<%=destSpritesCss%>/00-sprites.less'
				,options: '--css=<%=destSpritesCss%> --img=<%=destSpritesImg%> --less --url=<%=staticUriPrefix%> --namespace= --sprite-namespace= --recursive --crop --optipng'
			}
		}
		,less_imports: {
			inline: {
				src: '<%=sources.inline_css%>'
				,dest: '<%=tmp%>/inline-imports.less'
			},
			external: {
				options: {}
				,src: '<%=sources.external_css%>'
				,dest: '<%=tmp%>/external-imports.less'
			}
		}
		,jshint: {
			options: {
				// report but don't fail
				force: true
				// enforce
				,latedef: true
				,undef: true
				//relax
				,laxcomma: true
				,smarttabs: true
				,expr: true
				,asi: true
				,loopfunc: true
				// environment
				,browser: true
				,globals: {
					 $: true
					,Tc: true
					,ModuleTest: true
					,log: true
				}
			}
			,inline: ['<%=sources.jshint_inline%>']
			,external: ['<%=sources.jshint_external%>']
			//,module_tests: ['<%=sources.jshint_module_test%>']
		}
		,concat: {
			inline_scripts: {
				options: {
					banner: '/*! Inline script dependencies for page bootstrapping */\n'
				}
				,src: '<%=sources.inline_js%>'
				,dest: '<%=destJs%>/inline.js'
			}
			,external_scripts: {
				 src: '<%=sources.external_js%>'
				,dest: '<%=destJs%>/external.js'
			}
			,module_tests: {
				 src: '<%=sources.module_test_js%>'
				,dest: '<%=destJs%>/test.js'
			}
		},
		uglify: {
			inline: {
				options: {
					preserveComments: 'some'
				}
				,src: '<%=destJs%>/inline.js'
				,dest: '<%=destJs%>/inline.min.js'
			},
			external: {
				src: '<%=destJs%>/external.js'
				,dest: '<%=destJs%>/external.min.js'
			}
		}
		,less: {
			inline: {
				options: {
					// cssmin will not create file if the output is empty. a special comment fixes this.
					banner: '/*! */'
				}
				,src: '<%=tmp%>/inline-imports.less'
				,dest: '<%=destCss%>/inline.css'
			},
			external: {
				options: {
					banner: "@static-prefix: '<%=staticUriPrefix%>';"
				}
				,src: '<%=tmp%>/external-imports.less'
				,dest: '<%=destCss%>/external.css'
			}
		},
		cssmin: {
			inline: {
				files: {
					'<%=destCss%>/inline.min.css': ['<%=destCss%>/inline.css']
				}
			},
			external: {
				files: {
					'<%=destCss%>/external.min.css': ['<%=destCss%>/external.css']
				}
			}
		}
		,watch: {
			sprites: {
				files: ['<%=sources.sprites%>*.png', '<%=sources.sprites%>*.jpg']
				,tasks: ['build-sprites', 'build-external-css']
			},
			inline_styles: {
				files: ['<%=sources.inline_css%>']
				,tasks: ['build-inline-css']
			},
			external_styles: {
				files: ['<%=sources.external_css%>']
				,tasks: ['build-external-css']
			}
			,inline_scripts: {
				files: ['<%=sources.inline_js%>']
				,tasks: ['build-inline-js']
			}
			,external_scripts: {
				files: ['<%=sources.external_js%>']
				,tasks: ['build-external-js']
			}
			,module_tests: {
				files: ['<%=sources.module_test_js%>']
				,tasks: ['build-module-tests']
			}
		}
	});

	// get dependencies
	grunt.loadNpmTasks('grunt-glue');
	grunt.loadNpmTasks('assemble-less');
	grunt.loadNpmTasks('grunt-less-imports');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');

	// create build tasks                            // use actual task name (first part before colon)!
	grunt.registerTask('build-sprites',              ['glue']);

	grunt.registerTask('build-inline-js',            ['jshint:inline',   'concat:inline_scripts',   'uglify:inline']);
	grunt.registerTask('build-external-js',          ['jshint:external', 'concat:external_scripts', 'uglify:external']);
	grunt.registerTask('build-inline-css',           ['less_imports:inline',   'less:inline',   'cssmin:inline']);
	grunt.registerTask('build-external-css',         ['less_imports:external', 'less:external', 'cssmin:external']);
	grunt.registerTask('build-module-tests',         [/*'jshint:module_tests',*/ 'concat:module_tests']);

	var defaultTask = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'
		,'watch'
	];

	// If sprites building is not enabled in the app config, remove it.
	!cfg.enableSpritesBuilding && defaultTask.shift();

	// aggregate default task
	grunt.registerTask('default', defaultTask);

};<commit_msg>build improvements<commit_after>module.exports = function(grunt) {

	var path = require('path')

		// Merge configuration data
		,cfg = require('./app_modules/configure')
			.merge('_config/', [
				 'default'
				,'project'
				,'secret'
				,'local'
			]).get()

		,modulesPattern = path.join(cfg.paths.modulesBaseDir, cfg.moduleDirName.replace('{{name}}', '*'))
		,buildBaseDir = path.join(cfg.paths.staticBaseDir, cfg.static.build.baseDirName); // build.baseDirName may be empty
	;

	grunt.initConfig({

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

		,staticUriPrefix:   cfg.staticUriPrefix

		// Sources base paths

		,tcInline:          cfg.paths.inline
		,tcBase:            cfg.paths.base
		,tcModules:         modulesPattern
		,tcApplication:     cfg.paths.application
		,staticDir:         cfg.paths.staticBaseDir

		// Output destinations

		,buildBaseDir: buildBaseDir
		,tmp:               '<%=buildBaseDir%>/tmp'
		,destJs:            '<%=buildBaseDir%>'
		,destCss:           '<%=buildBaseDir%>'
		,destSpritesCss:    '<%=tcBase%>/css/sprites' // technically this should go in tmp, but we want the generated classes in our base css for easy lookup.
		,destSpritesImg:    '<%=buildBaseDir%>'

		// Sources patterns

		,sources: {
			inline_css: [
				 '<%=tcInline%>/css/lib/*.css'
				,'<%=tcInline%>/css/*.less'
			]
			,external_css: [
				 '<%=tcBase%>/css/sprites/*.less'
				,'<%=tcBase%>/css/lib/*.css'
				,'<%=tcBase%>/css/elements/*.less'
				,'<%=tcModules%>/*.less'
				,'<%=tcModules%>/skin/*.less'
				,'<%=tcApplication%>/css/*.less'
			]
			,inline_js: [
				 '<%=tcInline%>/js/lib/*.js'
				,'<%=tcInline%>/js/*.js'
			]
			,external_js: [
				 '<%=tcBase%>/js/lib/*.js'
				,'<%=tcBase%>/js/*.js'
				,'<%=tcModules%>/*.js'
				,'<%=tcModules%>/skin/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,module_test_js: [
				 '<%=staticDir%>/test/*.js'
				,'<%=tcModules%>/test/*.js'
			]
			,jshint_inline: [
				 '<%=tcInline%>/js/*.js'
			]
			,jshint_external: [
				 '<%=tcModules%>/*.js'
				,'<%=tcModules%>/skin/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,jshint_module_test: [
				 //'<%=staticDir%>/_static/test/*.js'
				//,'<%=tcModules%>/test/*.js'
			]
			,sprites: [
				'<%=tcBase%>/css/sprites/'
				//,'<%=tcModules%>/sprites/'
			]
		}

		//////////////////////////////////////////////////////////////

		,glue: {
			icons: {
				src: '<%=sources.sprites%>'
				//,dest: '<%=destSpritesCss%>/00-sprites.less'
				,options: '--css=<%=destSpritesCss%> --img=<%=destSpritesImg%> --less --url=<%=staticUriPrefix%> --namespace= --sprite-namespace= --recursive --crop --optipng'
			}
		}
		,less_imports: {
			inline: {
				src: '<%=sources.inline_css%>'
				,dest: '<%=tmp%>/inline-imports.less'
			},
			external: {
				options: {}
				,src: '<%=sources.external_css%>'
				,dest: '<%=tmp%>/external-imports.less'
			}
		}
		,jshint: {
			options: {
				// report but don't fail
				force: true
				// enforce
				,latedef: true
				,undef: true
				//relax
				,laxcomma: true
				,smarttabs: true
				,expr: true
				,asi: true
				,loopfunc: true
				// environment
				,browser: true
				,jquery: true
				,globals: {
					 $: true
					,Tc: true
					,ModuleTest: true
					,log: true
				}
			}
			,inline: ['<%=sources.jshint_inline%>']
			,external: ['<%=sources.jshint_external%>']
			//,module_tests: ['<%=sources.jshint_module_test%>']
		}
		,concat: {
			inline_scripts: {
				options: {
					banner: '/*! Inline script dependencies for page bootstrapping */\n'
				}
				,src: '<%=sources.inline_js%>'
				,dest: '<%=destJs%>/inline.js'
			}
			,external_scripts: {
				 src: '<%=sources.external_js%>'
				,dest: '<%=destJs%>/external.js'
			}
			,module_tests: {
				 src: '<%=sources.module_test_js%>'
				,dest: '<%=destJs%>/test.js'
			}
		},
		uglify: {
			inline: {
				options: {
					preserveComments: 'some'
				}
				,src: '<%=destJs%>/inline.js'
				,dest: '<%=destJs%>/inline.min.js'
			},
			external: {
				src: '<%=destJs%>/external.js'
				,dest: '<%=destJs%>/external.min.js'
			}
		}
		,less: {
			inline: {
				options: {
					// cssmin will not create file if the output is empty. a special comment fixes this.
					banner: '/*! Inline style dependencies for page bootstrapping */'
				}
				,src: '<%=tmp%>/inline-imports.less'
				,dest: '<%=destCss%>/inline.css'
			},
			external: {
				options: {
					banner: "@static-prefix: '<%=staticUriPrefix%>';"
				}
				,src: '<%=tmp%>/external-imports.less'
				,dest: '<%=destCss%>/external.css'
			}
		},
		cssmin: {
			inline: {
				files: {
					'<%=destCss%>/inline.min.css': ['<%=destCss%>/inline.css']
				}
			},
			external: {
				files: {
					'<%=destCss%>/external.min.css': ['<%=destCss%>/external.css']
				}
			}
		}
		,watch: {
			sprites: {
				files: ['<%=sources.sprites%>*.png', '<%=sources.sprites%>*.jpg']
				,tasks: ['build-sprites', 'build-external-css']
			},
			inline_styles: {
				files: ['<%=sources.inline_css%>']
				,tasks: ['build-inline-css']
			},
			external_styles: {
				files: ['<%=sources.external_css%>']
				,tasks: ['build-external-css']
			}
			,inline_scripts: {
				files: ['<%=sources.inline_js%>']
				,tasks: ['build-inline-js']
			}
			,external_scripts: {
				files: ['<%=sources.external_js%>']
				,tasks: ['build-external-js']
			}
			,module_tests: {
				files: ['<%=sources.module_test_js%>']
				,tasks: ['build-module-tests']
			}
		}
	});

	// get dependencies
	grunt.loadNpmTasks('grunt-glue');
	grunt.loadNpmTasks('assemble-less');
	grunt.loadNpmTasks('grunt-less-imports');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');

	// create build tasks                            // use actual task name (first part before colon)!
	grunt.registerTask('build-sprites',              ['glue']);

	grunt.registerTask('build-inline-js',            ['concat:inline_scripts', 'uglify:inline', 'jshint:inline']);
	grunt.registerTask('build-external-js',          ['concat:external_scripts', 'uglify:external', 'jshint:external',]);
	grunt.registerTask('build-inline-css',           ['less_imports:inline',   'less:inline',   'cssmin:inline']);
	grunt.registerTask('build-external-css',         ['less_imports:external', 'less:external', 'cssmin:external']);
	grunt.registerTask('build-module-tests',         [ 'concat:module_tests' /*, 'jshint:module_tests'*/]);

	var defaultTask = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'
		,'watch'
	];

	// If sprites building is not enabled in the app config, remove it.
	!cfg.enableSpritesBuilding && defaultTask.shift();

	// aggregate default task
	grunt.registerTask('default', defaultTask);

};<|endoftext|>


<commit_before>/**
 * brandung FE Workflow 3.0
 * https://[github-URL]
 *
 * Copyright (c) 2015 brandung GmbH & Co.KG
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {

	/**
	 * Define our global vars
	 */
	var Config = {},
		configFile = './grunt/config.js',
		Helpers = require('./grunt/helpers'),
		_ = grunt.util._,
		path = require('path');

	/**
	 * Measures the time each task takes
	 *
	 * https://www.npmjs.com/package/time-grunt
	 */
	require("time-grunt")(grunt);

	/**
	 * Load the notification plugin
	 */
	grunt.loadNpmTasks('grunt-notify');

	/**
	 * Optional define a sub-project folder.
	 * eg. --target=[folder-name]
	 */
	//TODO: save targets in Config.targets Array. On task run do prompt with target selection
	//TODO: build multitask to do this
	/*
	var target = grunt.option('target') || '';

	if (target) {
	 Config.PRIVATE_DIR += '/' + target;
	 Config.PUBLIC_DIR += '/' + target;
	}
	*/

	/**
	 * Check if the Config.SYSTEM var is already set
	 * and load the config.js file.
	 */
	if (!Helpers.checkString('%%system%%', configFile)) {
		Config = require(configFile);
	}

	/**
	 * We have to bind the 'Config' object to our taskConfig,
	 * so we have access to the global vars for e.g. using `<% %>` template strings.
	 */
	var taskConfig = {
		Config: Config
	};

	/**
	 * Loads task options from 'grunt/tasks/' folder
	 * and loads tasks defined in `package.json`.
	 * Used jitGrunt to load only the modules that are currently needed
	 * instead of loading all modules on every build.
	 *
	 * https://www.npmjs.com/package/load-grunt-config
	 */
	taskConfig = _.extend(taskConfig,
		require('load-grunt-config')(grunt, {
			configPath: path.join(process.cwd(), 'grunt/tasks'),
			jitGrunt: {
				staticMappings: {
					bower: 'grunt-bower-task',
					replace: 'grunt-text-replace'
				}
			},
			init: false
		})
	);

	/**
	 * Init our grunt config
	 */
	grunt.initConfig(taskConfig);

	/******************
	 * App Main Tasks *
	 ******************/

	/**
	 * The 'default' task
	 */
	grunt.registerTask('default', 'Desc', [
		'confReady',
		'sass',
		'sassToHtml',
		'tasty_swig',
		'copy:privateUtilToPublicFolder',
		'copy:privateHandlerToPublicFolder',
		'copy:privateFunctionToPublicFolder',
		'copy:privateComponentToPublicFolder',
		'concat:mainJS',
		'clean:globalJsInPublicFolder'
	]);

	/**
	 * The `project:init` task configures your project,
	 * download the boilerplate and copy the assets
	 * into the given folder structure.
	 */
	grunt.registerTask('project:init', 'Start the initializing process', [
		'prompt:init',
		'replace:init',
		'confReady',
		'mkdir:projectStructure',
		'bower:fetchHtmlBoilerplate',
		'replace:pathPlaceholder',
		'copy:privateLibsToPublicFolder',
		'copy:privateRootFilesToRoot',
		'clean:privateRootFiles',
		'copy:hotfixjsToPublicFolder',
		'copy:hotfixcssToPublicFolder',
		'clean:rootFilesInPrivateFolder',
		'default',
		'project:serve'
	]);

	/**
	 * The 'project:serve' task for developing
	 */
	grunt.registerTask('project:serve', [
		'default',
		'browserSync',
		'watch'
	]);

	/**
	 * The 'project:finish' task prepares files for deployment
	 */
	grunt.registerTask('project:finish', [
		'default',
		'replace:deleteCssBlock',
		'replace:importJsStorageKey',
		'replace:deleteJsBlock',
		'clean:bundleFolder',
		'uglify:component',
		'uglify:global',
		'assetBundle',
		'uglify:mainJS',
		'cssmin',
		'notify:finish'
	]);

	/**
	 * ZIP the project
	 */
	grunt.registerTask('create:zip', [
		'confReady',
		'mkdir:zipFolder',
		'copy:publicFolderToZipFolder',
		'copy:templatesToZipFolder',
		'copy:rootFilesToZipFolder',
		'replace:zipFolderAssetPath',
		'clean:zipTplFolder',
		'zip',
		'clean:zipFolder'
	]);

	/**
	 * Create 'styleguide'
	 */
	grunt.registerTask('create:styleguide', [
		'confReady',
		'sassToHtml'
	]);

	/**
	 * Create new component
	 */
	grunt.registerTask('create:component', [
		'confReady',
		'file-creator:componentFiles',
		'replace:addNewComponentImport',
		'replace:includeSwigComponentPartial',
		'default',
		'project:serve'
	]);
};
<commit_msg>optimized create:zip task<commit_after>/**
 * brandung FE Workflow 3.0
 * https://[github-URL]
 *
 * Copyright (c) 2015 brandung GmbH & Co.KG
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {

	/**
	 * Define our global vars
	 */
	var Config = {},
		configFile = './grunt/config.js',
		Helpers = require('./grunt/helpers'),
		_ = grunt.util._,
		path = require('path');

	/**
	 * Measures the time each task takes
	 *
	 * https://www.npmjs.com/package/time-grunt
	 */
	require("time-grunt")(grunt);

	/**
	 * Load the notification plugin
	 */
	grunt.loadNpmTasks('grunt-notify');

	/**
	 * Optional define a sub-project folder.
	 * eg. --target=[folder-name]
	 */
	//TODO: save targets in Config.targets Array. On task run do prompt with target selection
	//TODO: build multitask to do this
	/*
	var target = grunt.option('target') || '';

	if (target) {
	 Config.PRIVATE_DIR += '/' + target;
	 Config.PUBLIC_DIR += '/' + target;
	}
	*/

	/**
	 * Check if the Config.SYSTEM var is already set
	 * and load the config.js file.
	 */
	if (!Helpers.checkString('%%system%%', configFile)) {
		Config = require(configFile);
	}

	/**
	 * We have to bind the 'Config' object to our taskConfig,
	 * so we have access to the global vars for e.g. using `<% %>` template strings.
	 */
	var taskConfig = {
		Config: Config
	};

	/**
	 * Loads task options from 'grunt/tasks/' folder
	 * and loads tasks defined in `package.json`.
	 * Used jitGrunt to load only the modules that are currently needed
	 * instead of loading all modules on every build.
	 *
	 * https://www.npmjs.com/package/load-grunt-config
	 */
	taskConfig = _.extend(taskConfig,
		require('load-grunt-config')(grunt, {
			configPath: path.join(process.cwd(), 'grunt/tasks'),
			jitGrunt: {
				staticMappings: {
					bower: 'grunt-bower-task',
					replace: 'grunt-text-replace'
				}
			},
			init: false
		})
	);

	/**
	 * Init our grunt config
	 */
	grunt.initConfig(taskConfig);

	/******************
	 * App Main Tasks *
	 ******************/

	/**
	 * The 'default' task
	 */
	grunt.registerTask('default', 'Desc', [
		'confReady',
		'sass',
		'sassToHtml',
		'tasty_swig',
		'copy:privateUtilToPublicFolder',
		'copy:privateHandlerToPublicFolder',
		'copy:privateFunctionToPublicFolder',
		'copy:privateComponentToPublicFolder',
		'concat:mainJS',
		'clean:globalJsInPublicFolder'
	]);

	/**
	 * The `project:init` task configures your project,
	 * download the boilerplate and copy the assets
	 * into the given folder structure.
	 */
	grunt.registerTask('project:init', 'Start the initializing process', [
		'prompt:init',
		'replace:init',
		'confReady',
		'mkdir:projectStructure',
		'bower:fetchHtmlBoilerplate',
		'replace:pathPlaceholder',
		'copy:privateLibsToPublicFolder',
		'copy:privateRootFilesToRoot',
		'clean:privateRootFiles',
		'copy:hotfixjsToPublicFolder',
		'copy:hotfixcssToPublicFolder',
		'clean:rootFilesInPrivateFolder',
		'default',
		'project:serve'
	]);

	/**
	 * The 'project:serve' task for developing
	 */
	grunt.registerTask('project:serve', [
		'default',
		'browserSync',
		'watch'
	]);

	/**
	 * The 'project:finish' task prepares files for deployment
	 */
	grunt.registerTask('project:finish', [
		'default',
		'replace:deleteCssBlock',
		'replace:importJsStorageKey',
		'replace:deleteJsBlock',
		'clean:bundleFolder',
		'uglify:component',
		'uglify:global',
		'assetBundle',
		'uglify:mainJS',
		'cssmin',
		'notify:finish'
	]);

	/**
	 * ZIP the project
	 */
	grunt.registerTask('create:zip', [
		'confReady',
		'mkdir:zipFolder',
		'copy:publicFolderToZipFolder',
		'copy:templatesToZipFolder',
		'copy:rootFilesToZipFolder',
		'replace:zipFolderAssetPath',
		'replace:zipCSSPath',
		'clean:zipTplFolder',
		'zip',
		'clean:zipFolder'
	]);

	/**
	 * Create 'styleguide'
	 */
	grunt.registerTask('create:styleguide', [
		'confReady',
		'sassToHtml'
	]);

	/**
	 * Create new component
	 */
	grunt.registerTask('create:component', [
		'confReady',
		'file-creator:componentFiles',
		'replace:addNewComponentImport',
		'replace:includeSwigComponentPartial',
		'default',
		'project:serve'
	]);
};
<|endoftext|>


<commit_before>/* global module */

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

  var bs = require('browser-sync');

  require('time-grunt')(grunt);

  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    usebanner: 'grunt-banner'
  });

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    bwr: grunt.file.readJSON('bower.json'),
    project: {
      src: './src',
      dist: './dist',
      index: '<%= project.dist %>/index.html',
      assets: '<%= project.dist %>/assets',
      components: 'bower_components',
      banner: '/*!\n' +
      ' * <%= pkg.title %> v<%= pkg.version %> (<%= grunt.template.today("dd.mm.yyyy") %>)\n' +
      ' * Copyright by <%= pkg.author %>\n' +
      ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
      ' */\n'
    },

    clean: {
      options: {
        force: true
      },
      dist: {
        src: ['<%= project.dist %>']
      }
    },

    sass: {
      dist: {
        options: {
          noLineComments: false,
          relativeAssets: true,
          sourceMap: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/styles',
            dest: '<%= project.assets %>/styles',
            src: '**/*.{scss,sass}',
            ext: '.css'
          }
        ]
      }
    },

    wiredep: {
      html: {
        src: '<%= project.index %>',
        exclude: ['<%= project.components %>/bootstrap-sass-official/assets/javascripts/bootstrap.js', '<%= project.components %>/modernizr/modernizr.js']
      },
      scss: {
        src: '<%= project.src %>/styles/**/*.{scss,sass}'
      }
    },

    modernizr: {
      dist: {
        options: {
          preserveComments: false
        },
        uglify: true,
        devFile: '<%= project.components %>/modernizr/modernizr.js',
        outputFile: '<%= project.assets %>/scripts/modernizr.custom.min.js',
        extra: {
          shiv: true,
          printshiv: true,
          load: true,
          mq: false,
          cssclasses: true
        },
        extensibility: {
          addtest: false,
          prefixed: true,
          teststyles: false,
          testprops: false,
          testallprops: false,
          hasevents: false,
          prefixes: true,
          domprefixes: true
        }
      }
    },

    jshint: {
      options: {
        jshintrc: '<%= project.src %>/scripts/.jshintrc'
      },
      dist: ['Gruntfile.js', '<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
    },

    jscs: {
      options: {
        config: '<%= project.src %>/scripts/.jscsrc'
      },
      dist: {
        src: ['<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
      }
    },

    ngAnnotate: {
      dist: {
        options: {
          sourceMap: false,
          singleQuotes: true
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts'
          }
        ]
      }
    },

    uglify: {
      dist: {
        options: {
          sourceMap: false,
          preserveComments: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts',
            ext: '.min.js'
          }
        ]
      }
    },

    autoprefixer: {
      options: {
        browsers: ['Android 2.3', 'Android >= 4', 'Chrome >= 20', 'Firefox >= 24', 'Explorer >= 8', 'iOS >= 6', 'Opera >= 12', 'Safari >= 6']
      },
      dist: {
        options: {
          map: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    cssmin: {
      dist: {
        options: {
          sourceMap: false,
          compatibility: 'ie8',
          keepSpecialComments: '*',
          advanced: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles',
            ext: '.min.css'
          }
        ]
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= project.banner %>'
      },
      css: {
        files: {
          src: ['<%= project.assets %>/styles/main.css', '<%= project.assets %>/styles/main.min.css']
        }
      },
      js: {
        files: {
          src: ['<%= project.assets %>/scripts/main.js', '<%= project.assets %>/scripts/main.min.js']
        }
      }
    },

    csscomb: {
      options: {
        config: '<%= project.src %>/styles/.csscomb.json'
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    copy: {
      fonts: {
        expand: true,
        cwd: '<%= project.src %>/fonts',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      },
      vendor: {
        expand: true,
        cwd: '<%= project.src %>/scripts/vendor',
        src: '*',
        dest: '<%= project.assets %>/scripts/vendor'
      },
      svg: {
        expand: true,
        cwd: '<%= project.src %>/images',
        src: ['**/*.svg'],
        dest: '<%= project.assets %>/images'
      },
      glyphicons: {
        expand: true,
        cwd: '<%= project.vendor %>/bootstrap-sass-official/assets/fonts/bootstrap/*',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      }
    },

    jade: {
      options: {
        pretty: true
      },
      dist: {
        expand: true,
        cwd: '<%= project.src %>/templates',
        src: ['**/*.jade', '!**/_*.jade'],
        dest: '<%= project.dist %>',
        ext: '.html'
      }
    },

    useminPrepare: {
      options: {
        dest: '<%= project.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      },
      html: '<%= project.index %>'
    },

    usemin: {
      options: {
        assetsDirs: ['<%= project.components %>']
      },
      html: '<%= project.index %>',
      css: ['<%= project.assets %>/styles/**/*.css']
    },

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

    uncss: {
      dist: {
        options: {
          stylesheets: ['../<%= project.assets %>/styles/main.css']
        },
        files: {
          '<%= project.assets %>/styles/main.css': ['<%= project.dist %>/**/*.html']
        }
      }
    },

    watch: {
      options: {
        spawn: false
      },
      scripts: {
        files: '<%= project.src %>/scripts/**/*.js',
        tasks: ['ngAnnotate', 'uglify:dist', 'usebanner:js', 'bs-inject']
      },
      styles: {
        files: '<%= project.src %>/styles/**/*.{scss,sass}',
        tasks: ['newer:imagemin', 'newer:copy', 'sass', 'uncss', 'csscomb', 'autoprefixer', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      templates: {
        files: '<%= project.src %>/templates/**/*.jade',
        tasks: ['newer:imagemin', 'newer:copy', 'jade', 'wiredep', 'useminPrepare', 'usemin', 'ngAnnotate', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      images: {
        files: '<%= project.src %>/images',
        tasks: ['newer:imagemin', 'newer:copy', 'bs-inject']
      }
    }
  });

  grunt.registerTask('bs-init', 'Start BrowserSync Server', function () {
    var done = this.async();

    bs({
      server: './dist',
      notify: false,
      ghostMode: false
    }, function () {
      done();
    });
  });

  grunt.registerTask('bs-inject', 'Reload Files in Browser', function () {
    return bs.reload();
  });

  grunt.registerTask('default', ['lint', 'build', 'serve']);

  grunt.registerTask('lint', ['jshint', 'jscs']);

  grunt.registerTask('serve', ['bs-init', 'watch']);

  grunt.registerTask('build', ['clean', 'imagemin', 'copy', 'jade', 'wiredep', 'useminPrepare', 'sass', 'uncss', 'modernizr', 'autoprefixer', 'cssmin:generated', 'ngAnnotate', 'concat:generated', 'uglify:generated', 'usemin', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner']);
};
<commit_msg>Small improvements in `Gruntfile`<commit_after>/* node: true */

'use strict';

module.exports = function (grunt) {
  var bs = require('browser-sync');

  require('time-grunt')(grunt);

  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    usebanner: 'grunt-banner'
  });

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    bwr: grunt.file.readJSON('bower.json'),
    project: {
      src: 'src',
      dist: 'dist',
      index: '<%= project.dist %>/index.html',
      assets: '<%= project.dist %>/assets',
      components: grunt.file.readJSON('.bowerrc').directory,
      banner: '/*!\n' +
      ' * <%= pkg.title %> v<%= pkg.version %> (<%= grunt.template.today("dd.mm.yyyy") %>)\n' +
      ' * Copyright by <%= pkg.author %>\n' +
      ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
      ' */\n'
    },

    clean: {
      options: {
        force: true
      },
      dist: {
        dot: true,
        src: ['<%= project.dist %>/*', '!<%= project.dist %>/.git*']
      }
    },

    sass: {
      dist: {
        options: {
          noLineComments: false,
          relativeAssets: true,
          sourceMap: true
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/styles',
            dest: '<%= project.assets %>/styles',
            src: '**/*.{scss,sass}',
            ext: '.css'
          }
        ]
      }
    },

    wiredep: {
      html: {
        src: '<%= project.index %>',
        exclude: ['<%= project.components %>/bootstrap-sass-official/assets/javascripts/bootstrap.js', '<%= project.components %>/modernizr/modernizr.js']
      },
      scss: {
        src: '<%= project.src %>/styles/**/*.{scss,sass}'
      }
    },

    modernizr: {
      dist: {
        options: {
          preserveComments: false
        },
        uglify: true,
        devFile: '<%= project.components %>/modernizr/modernizr.js',
        outputFile: '<%= project.assets %>/scripts/modernizr.custom.min.js',
        extra: {
          shiv: true,
          printshiv: true,
          load: true,
          mq: false,
          cssclasses: true
        },
        extensibility: {
          addtest: false,
          prefixed: true,
          teststyles: false,
          testprops: false,
          testallprops: false,
          hasevents: false,
          prefixes: true,
          domprefixes: true
        }
      }
    },

    jshint: {
      options: {
        jshintrc: '<%= project.src %>/scripts/.jshintrc'
      },
      dist: ['Gruntfile.js', '<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
    },

    jscs: {
      options: {
        config: '<%= project.src %>/scripts/.jscsrc'
      },
      dist: {
        src: ['Gruntfile.js', '<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
      }
    },

    ngAnnotate: {
      dist: {
        options: {
          sourceMap: true,
          singleQuotes: true
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts'
          }
        ]
      }
    },

    uglify: {
      dist: {
        options: {
          sourceMap: false,
          preserveComments: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts',
            ext: '.min.js'
          }
        ]
      }
    },

    autoprefixer: {
      options: {
        browsers: ['Android 2.3', 'Android >= 4', 'Chrome >= 20', 'Firefox >= 24', 'Explorer >= 8', 'iOS >= 6', 'Opera >= 12', 'Safari >= 6']
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    cssmin: {
      dist: {
        options: {
          compatibility: 'ie8',
          keepSpecialComments: '*',
          advanced: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles',
            ext: '.min.css'
          }
        ]
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= project.banner %>'
      },
      css: {
        files: {
          src: ['<%= project.assets %>/styles/main.css', '<%= project.assets %>/styles/main.min.css']
        }
      },
      js: {
        files: {
          src: ['<%= project.assets %>/scripts/main.js', '<%= project.assets %>/scripts/main.min.js']
        }
      }
    },

    csscomb: {
      options: {
        config: '<%= project.src %>/styles/.csscomb.json'
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    copy: {
      fonts: {
        expand: true,
        cwd: '<%= project.src %>/fonts',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      },
      vendor: {
        expand: true,
        cwd: '<%= project.src %>/scripts/vendor',
        src: '*',
        dest: '<%= project.assets %>/scripts/vendor'
      },
      svg: {
        expand: true,
        cwd: '<%= project.src %>/images',
        src: ['**/*.svg'],
        dest: '<%= project.assets %>/images'
      },
      glyphicons: {
        expand: true,
        cwd: '<%= project.vendor %>/bootstrap-sass-official/assets/fonts/bootstrap/*',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      }
    },

    jade: {
      options: {
        pretty: true
      },
      dist: {
        expand: true,
        cwd: '<%= project.src %>/templates',
        src: ['**/*.jade', '!**/_*.jade'],
        dest: '<%= project.dist %>',
        ext: '.html'
      }
    },

    useminPrepare: {
      options: {
        dest: '<%= project.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      },
      html: '<%= project.index %>'
    },

    usemin: {
      options: {
        assetsDirs: ['<%= project.components %>']
      },
      html: '<%= project.index %>',
      css: ['<%= project.assets %>/styles/**/*.css']
    },

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

    uncss: {
      dist: {
        options: {
          stylesheets: ['../<%= project.assets %>/styles/main.css']
        },
        files: {
          '<%= project.assets %>/styles/main.css': ['<%= project.dist %>/**/*.html']
        }
      }
    },

    watch: {
      options: {
        spawn: false
      },
      scripts: {
        files: '<%= project.src %>/scripts/**/*.js',
        tasks: ['ngAnnotate', 'uglify:dist', 'usebanner:js', 'bs-inject']
      },
      styles: {
        files: '<%= project.src %>/styles/**/*.{scss,sass}',
        tasks: ['newer:imagemin', 'newer:copy', 'sass', 'uncss', 'csscomb', 'autoprefixer', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      templates: {
        files: '<%= project.src %>/templates/**/*.jade',
        tasks: ['newer:imagemin', 'newer:copy', 'jade', 'wiredep', 'useminPrepare', 'usemin', 'ngAnnotate', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      images: {
        files: '<%= project.src %>/images',
        tasks: ['newer:imagemin', 'newer:copy', 'bs-inject']
      }
    }
  });

  grunt.registerTask('bs-init', 'Start BrowserSync Server', function () {
    var done = this.async();

    bs({
      server: 'dist',
      notify: false,
      ghostMode: false
    }, function () {
      done();
    });
  });

  grunt.registerTask('bs-inject', 'Reload Files in Browser', function () {
    return bs.reload();
  });

  grunt.registerTask('default', ['lint', 'build', 'serve']);

  grunt.registerTask('lint', ['jshint', 'jscs']);

  grunt.registerTask('serve', ['bs-init', 'watch']);

  grunt.registerTask('build', ['clean', 'imagemin', 'copy', 'jade', 'wiredep', 'useminPrepare', 'sass', 'uncss', 'modernizr', 'autoprefixer', 'cssmin:generated', 'ngAnnotate', 'concat:generated', 'uglify:generated', 'usemin', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner']);
};
<|endoftext|>


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

  var appConfig = {
    info: grunt.file.readJSON('appinfo.json'),
    keys: grunt.file.readJSON('keys.json'),
    enableLogs: false,
    paths: {
      bundle: 'src/js/pebble-js-app.js',
      testBundle: 'test/js/specs-bundle.js'
    }
  };

  grunt.initConfig({

    config: appConfig,

    copy: {
      main: {
        options: {
          process: function (content, path) {
            return grunt.template.process(content);
          }
        },
        files: {
          'src/appinfo.h': ['src/appinfo.tpl.h']
        }
      },
    },

    jshint: {
      files: [
        'Gruntfile.js',
        'src/js/**/*.js',
        '!<%= config.paths.bundle %>',
        '!src/js/*.tpl.js',
        'test/js/specs/**/*.js',
        'test/js/helpers/**/*.js'
      ],
      options: {
        jshintrc: true
      }
    },

    browserify: {
      build: {
        options: {
          alias: {
            'request': './src/js/request.js',
            'request-callback-wrapper': './src/js/request-callback-wrapper.js'
          }
        },
        src: [
          'src/js/**/*.js',
          '!<%= config.paths.bundle %>',
          '!src/js/*.tpl.js'
        ],
        dest: '<%= config.paths.bundle %>'
      },
      test: {
        options: {
          browserifyOptions: {
            debug: true
          },
          alias: {
            'request': './test/js/mocks/request.js',
            'request-callback-wrapper': './src/js/request-callback-wrapper.js'
          }
        },
        src: [
          'test/js/specs/*.spec.js'
        ],
        dest: '<%= config.paths.testBundle %>'
      }
    },

    jasmine: {
      build: {
        options: {
          helpers: [
            'test/js/mocks/pebble.js',
            'test/js/mocks/navigator.js'
          ],
          specs: '<%= config.paths.testBundle %>',
          outfile: 'test/js/_SpecRunner.html',
          keepRunner: true
        }
      }
    },

    removelogging: {
      build: {
        src: '<%= config.paths.bundle %>'
      },
      test: {
        src: '<%= config.paths.testBundle %>'
      }
    },

    run: {
      options: {
        cwd: 'test/c/',
        failOnError: true
      },
      make: {
        cmd: 'make'
      },
      test: {
        cmd: './test'
      }
    },

    'gh-pages': {
      options: {
        base: 'config'
      },
      src: ['**/*']
    }

  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-gh-pages');
  grunt.loadNpmTasks('grunt-remove-logging');
  grunt.loadNpmTasks('grunt-run');

  grunt.registerTask('build', 'Build and test the system', function(target) {
    if (target == 'nologs')
      appConfig.enableLogs = false;

    var tasks = ['copy', 'jshint', 'browserify', 'removelogging:test', 'jasmine', 'run:make', 'run:test'];
    if (!appConfig.enableLogs)
      tasks.push('removelogging:build');
    grunt.task.run(tasks);
  });

  grunt.registerTask('default', ['build']);
  grunt.registerTask('deploy', ['gh-pages']);

};
<commit_msg>Re-enable logs<commit_after>module.exports = function(grunt) {

  var appConfig = {
    info: grunt.file.readJSON('appinfo.json'),
    keys: grunt.file.readJSON('keys.json'),
    enableLogs: true,
    paths: {
      bundle: 'src/js/pebble-js-app.js',
      testBundle: 'test/js/specs-bundle.js'
    }
  };

  grunt.initConfig({

    config: appConfig,

    copy: {
      main: {
        options: {
          process: function (content, path) {
            return grunt.template.process(content);
          }
        },
        files: {
          'src/appinfo.h': ['src/appinfo.tpl.h']
        }
      },
    },

    jshint: {
      files: [
        'Gruntfile.js',
        'src/js/**/*.js',
        '!<%= config.paths.bundle %>',
        '!src/js/*.tpl.js',
        'test/js/specs/**/*.js',
        'test/js/helpers/**/*.js'
      ],
      options: {
        jshintrc: true
      }
    },

    browserify: {
      build: {
        options: {
          alias: {
            'request': './src/js/request.js',
            'request-callback-wrapper': './src/js/request-callback-wrapper.js'
          }
        },
        src: [
          'src/js/**/*.js',
          '!<%= config.paths.bundle %>',
          '!src/js/*.tpl.js'
        ],
        dest: '<%= config.paths.bundle %>'
      },
      test: {
        options: {
          browserifyOptions: {
            debug: true
          },
          alias: {
            'request': './test/js/mocks/request.js',
            'request-callback-wrapper': './src/js/request-callback-wrapper.js'
          }
        },
        src: [
          'test/js/specs/*.spec.js'
        ],
        dest: '<%= config.paths.testBundle %>'
      }
    },

    jasmine: {
      build: {
        options: {
          helpers: [
            'test/js/mocks/pebble.js',
            'test/js/mocks/navigator.js'
          ],
          specs: '<%= config.paths.testBundle %>',
          outfile: 'test/js/_SpecRunner.html',
          keepRunner: true
        }
      }
    },

    removelogging: {
      build: {
        src: '<%= config.paths.bundle %>'
      },
      test: {
        src: '<%= config.paths.testBundle %>'
      }
    },

    run: {
      options: {
        cwd: 'test/c/',
        failOnError: true
      },
      make: {
        cmd: 'make'
      },
      test: {
        cmd: './test'
      }
    },

    'gh-pages': {
      options: {
        base: 'config'
      },
      src: ['**/*']
    }

  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-gh-pages');
  grunt.loadNpmTasks('grunt-remove-logging');
  grunt.loadNpmTasks('grunt-run');

  grunt.registerTask('build', 'Build and test the system', function(target) {
    if (target == 'nologs')
      appConfig.enableLogs = false;

    var tasks = ['copy', 'jshint', 'browserify', 'removelogging:test', 'jasmine', 'run:make', 'run:test'];
    if (!appConfig.enableLogs)
      tasks.push('removelogging:build');
    grunt.task.run(tasks);
  });

  grunt.registerTask('default', ['build']);
  grunt.registerTask('deploy', ['gh-pages']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
	var browsers = [{
		browserName: 'chrome',
		version: '27',
		platform: 'Windows 8'
	},{
		browserName: 'firefox',
		version: '21',
		platform: 'Windows 8'
	},{
		browserName: 'safari',
		version: '6',
		platform: 'OS X 10.8'
	}
  ];

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

    connect: {
      server: {},

      options: {
        port: 8000,
        base: 'tmp/tests'
      }
    },

    watch: {
      files: ['lib/**', 'vendor/*', 'test/tests/*'],
      tasks: []
    },

    copy: {
      main: {
        files: [
          {expand: true, cwd: 'dist/', src: ['**'], dest: 'tmp/tests/'}, // includes files in path
          {expand: true, cwd: 'test/', src: ['**'], dest: 'tmp/tests/'} // includes files in path
        ]
      }
    },

    'saucelabs-qunit': {
      all: {
        options: {
          urls: [
            'http://localhost:8000/index.html'
          ],
          tunnelTimeout: 5,
					build: process.env.TRAVIS_BUILD_NUMBER,
					concurrency: 3,
					browsers: browsers,
					testname: "Oasis.js qunit tests",
          testTimeout: 15000,
          testInterval: 5000
        }
      }
    }
  });

  // Load tasks from npm
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-saucelabs');

  grunt.registerTask('test', ['copy', 'connect', 'saucelabs-qunit']);
	grunt.registerTask('default', ['test']);
	grunt.registerTask('server', ['copy', 'connect', 'watch']);
};
<commit_msg>Increase testTimeout for Saucelabs<commit_after>module.exports = function(grunt) {
	var browsers = [{
		browserName: 'chrome',
		version: '27',
		platform: 'Windows 8'
	},{
		browserName: 'firefox',
		version: '21',
		platform: 'Windows 8'
	},{
		browserName: 'safari',
		version: '6',
		platform: 'OS X 10.8'
	}
  ];

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

    connect: {
      server: {},

      options: {
        port: 8000,
        base: 'tmp/tests'
      }
    },

    watch: {
      files: ['lib/**', 'vendor/*', 'test/tests/*'],
      tasks: []
    },

    copy: {
      main: {
        files: [
          {expand: true, cwd: 'dist/', src: ['**'], dest: 'tmp/tests/'}, // includes files in path
          {expand: true, cwd: 'test/', src: ['**'], dest: 'tmp/tests/'} // includes files in path
        ]
      }
    },

    'saucelabs-qunit': {
      all: {
        options: {
          urls: [
            'http://localhost:8000/index.html'
          ],
          tunnelTimeout: 5,
					build: process.env.TRAVIS_BUILD_NUMBER,
					concurrency: 3,
					browsers: browsers,
					testname: "Oasis.js qunit tests",
          testTimeout: 60 * 1000,
          testInterval: 5000
        }
      }
    }
  });

  // Load tasks from npm
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-saucelabs');

  grunt.registerTask('test', ['copy', 'connect', 'saucelabs-qunit']);
	grunt.registerTask('default', ['test']);
	grunt.registerTask('server', ['copy', 'connect', 'watch']);
};
<|endoftext|>


<commit_before>/*jslint node:true */

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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
            all: ['src/taboverride.js']
        },
        concat: {
            dist: {
                options: {
                    banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.homepage %>\r\n' +
                        'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | <%= pkg.licenses[0].url %> */\r\n\r\n' +
                        '/**\r\n' +
                        ' * @fileOverview <%= pkg.name %>\r\n' +
                        ' * @author       <%= pkg.author.name %>\r\n' +
                        ' * @version      <%= pkg.version %>\r\n' +
                        ' */\r\n\r\n'
                },
                src: ['src/taboverride.js'],
                dest: 'build/taboverride.js'
            }
        },
        uglify: {
            options: {
                compress: true,
                mangle: true,
                preserveComments: 'some'
            },
            dist: {
                options: {
                    sourceMap: 'build/taboverride.min.js.map',
                    sourceMappingURL: 'taboverride.min.js.map',
                    sourceMapPrefix: 1
                },
                files: {
                    // the min file is moved to the build directory via a custom task
                    // this is to ensure the "file" field is set correctly in the source map
                    'taboverride.min.js': ['build/taboverride.js']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask('moveMinJSFile', 'Moves the minified JS file to the build directory.', function () {
        grunt.task.requires(['uglify']);

        grunt.file.copy('taboverride.min.js', 'build/taboverride.min.js');
        grunt.file['delete']('taboverride.min.js');
    });

    grunt.registerTask('generateBowerManifest', 'Generates the bower.json file.', function () {
        grunt.config.requires(['pkg']);
        grunt.task.requires(['concat', 'uglify']);

        var contents = grunt.template.process('{\r\n' +
                '    "name": "<%= pkg.name %>",\r\n' +
                '    "version": "<%= pkg.version %>",\r\n' +
                '    "main": "./build/taboverride.js"\r\n' +
                '}\r\n');

        grunt.file.write('bower.json', contents);
    });

    // need to a create custom task for jsdoc-toolkit documentation

    grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'moveMinJSFile', 'generateBowerManifest']);
};
<commit_msg>generateBowerManifest task has no task dependencies<commit_after>/*jslint node: true */

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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
            all: ['src/taboverride.js']
        },
        concat: {
            dist: {
                options: {
                    banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.homepage %>\r\n' +
                        'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | <%= pkg.licenses[0].url %> */\r\n\r\n' +
                        '/**\r\n' +
                        ' * @fileOverview <%= pkg.name %>\r\n' +
                        ' * @author       <%= pkg.author.name %>\r\n' +
                        ' * @version      <%= pkg.version %>\r\n' +
                        ' */\r\n\r\n'
                },
                src: ['src/taboverride.js'],
                dest: 'build/taboverride.js'
            }
        },
        uglify: {
            options: {
                compress: true,
                mangle: true,
                preserveComments: 'some'
            },
            dist: {
                options: {
                    sourceMap: 'build/taboverride.min.js.map',
                    sourceMappingURL: 'taboverride.min.js.map',
                    sourceMapPrefix: 1
                },
                files: {
                    // the min file is moved to the build directory via a custom task
                    // this is to ensure the "file" field is set correctly in the source map
                    'taboverride.min.js': ['build/taboverride.js']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask('moveMinJSFile', 'Moves the minified JS file to the build directory.', function () {
        grunt.task.requires(['uglify']);

        grunt.file.copy('taboverride.min.js', 'build/taboverride.min.js');
        grunt.file['delete']('taboverride.min.js');
    });

    grunt.registerTask('generateBowerManifest', 'Generates the bower.json file.', function () {
        grunt.config.requires(['pkg']);

        var contents = grunt.template.process('{\r\n' +
                '    "name": "<%= pkg.name %>",\r\n' +
                '    "version": "<%= pkg.version %>",\r\n' +
                '    "main": "./build/taboverride.js"\r\n' +
                '}\r\n');

        grunt.file.write('bower.json', contents);
    });

    // need to a create custom task for jsdoc-toolkit documentation

    grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'moveMinJSFile', 'generateBowerManifest']);
};
<|endoftext|>