<commit_before>//Skeleton GruntFile
// ------------------
'use strict';
/*globals require, module */

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

module.exports = function(grunt) {

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

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

    // Configurable paths
    var config = {
        src: 'src',
        build: 'src/build',
        dist: 'dist',
        test: 'test',
        examples: 'examples',
        docs: 'docs',
        bower: 'bower_components'
    };

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

        // Project settings
        config: config,
        pkg: grunt.file.readJSON('package.json'),

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= config.src %>/**/*.js', '<%= config.examples %>/**/*.js'],
                tasks: ['preprocess']
            },
            build: {
                files: ['<%= config.src %>/build/{,*/}*.js'],
            },
            jstest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['test:watch']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            }
        },
        // The actual grunt server settings
        browserSync: {
            options: {
                open: true,
                port: 9000,
                watchTask: true,
                server: {
                    files: ['<%= config.examples %>/**/*.js', '<%= config.src %>/**/*.js'],
                    baseDir: '<%= config.examples %>',
                    directory: true,
                    routes: {
                        '/bower_components': 'bower_components',
                        '/dist': 'dist'
                    }
                },
            },
            todo: {
                bsFiles: {
                    src: [
                        '<%= config.examples %>/todo/*.js',
                        '<%= config.examples %>/todo/*.html',
                        '<%= config.examples %>/todo/*.css',
                        '<%= config.dist %>/**/*.js'
                    ]
                },
                options: {
                    watchTask: true,
                    server: {
                        directory: false,
                        baseDir: '<%= config.examples %>/todo',
                        index: 'index.html',
                        routes: {
                            '/bower_components': 'bower_components',
                            '/dist': 'dist'
                        }
                    }
                }
            },
            lab: {
                bsFiles: {
                    src: [
                        '<%= config.examples %>/lab/*.js',
                        '<%= config.examples %>/lab/*.html',
                        '<%= config.examples %>/lab/*.css',
                        '<%= config.dist %>/**/*.js'
                    ]
                },
                options: {
                    watchTask: true,
                    server: {
                        directory: false,
                        baseDir: '<%= config.examples %>/lab',
                        index: 'index.html',
                        routes: {
                            '/bower_components': 'bower_components',
                            '/dist': 'dist'
                        }
                    }
                }

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

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: true,
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%= config.src %>{,*/}*.js',
                '!<%= config.examples %>{,*/}*.js',
                'test/unit/**/*.js'
            ],
            test: ['test/**/<%= pkg.name %>.js']
        },

        // Mocha testing framework configuration options
        mochaTest: {
            tests: {
                options: {
                    require: 'test/unit/setup/node.js',
                    reporter: grunt.option('mocha-reporter') || 'nyan',
                    clearRequireCache: true,
                    mocha: require('mocha')
                },
                src: [
                    'test/unit/setup/helpers.js',
                    'test/unit/jskeleton-src/*.spec.js',
                    'test/unit/marionette-comp/*.spec.js'
                ]
            },
            src: {
                options: {
                    require: 'test/unit/setup/node.js',
                    reporter: grunt.option('mocha-reporter') || 'nyan',
                    clearRequireCache: true,
                    mocha: require('mocha')
                },
                src: [
                    'test/unit/setup/helpers.js',
                    'test/unit/jskeleton-src/*.spec.js'
                ]
            }
        },
        // Automatically inject Bower components into the HTML file
        wiredep: {
            task: {
                //ignorePath: /^\/|\.\.\//,
                src: ['<%= config.examples %>/**/*.html']
            },
            options: {

            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= config.dist %>/jskeleton.min.js': [
                        '<%= config.dist %>/jskeleton.js'
                    ]
                }
            }
        },
        concat: {
            options: {
                stripBanners: true,
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
                    '<%= grunt.template.today("yyyy-mm-dd") %> \n */'

            },
            dist: {
                src: [
                    '<%= config.dist %>/<%= pkg.name %>.js'
                ],
                dest: '<%= config.dist %>/<%= pkg.name %>.js'
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= config.src %>',
                    dest: '<%= config.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'styles/fonts/{,*/}*.*'
                    ]
                }, {
                    src: 'node_modules/apache-server-configs/dist/.htaccess',
                    dest: '<%= config.dist %>/.htaccess'
                }]
            },
            coverage: {
                expand: true,
                flatten: true,
                src: ['<%= config.dist %>/*.js'],
                dest: 'test/coverage/instrument/build'
            }
        },
        preprocess: {
            'default': {
                src: '<%= config.build %>/main.js',
                dest: '<%= config.dist %>/<%= pkg.name %>.js'
            },
            'lite': {
                src: '<%= config.build %>/main-lite.js',
                dest: '<%= config.dist %>/<%= pkg.name %>_lite.js'
            }
        },
        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [],
            test: [],
            dist: []
        },
        docco: {
            options: {
                dst: './docs',
                layout: 'parallel'
            },
            docs: {
                files: [{
                    expand: true,
                    cwd: '<%= config.dist %>',
                    src: [
                        '<%= pkg.name %>_lite.js',
                    ]
                }]
            }
        },
        env: {
            coverage: {
                APP_DIR_FOR_CODE_COVERAGE: '../../../test/src/'
            }
        },
        instrument: {
            files: 'src/**/*.js',
            options: {
                lazy: true,
                basePath: 'test'
            }
        },
        storeCoverage: {
            options: {
                dir: 'coverage'
            }
        },
        makeReport: {
            src: 'coverage/**/*.json',
            options: {
                type: 'lcov',
                dir: 'coverage',
                print: 'detail'
            }
        },
        plato: {
            report: {
                files: {
                    'metrics': ['src/**/*.js', 'test/**/*.js']
                }
            }
        },

        coveralls: {
            'default': {
                src: 'coverage/lcov.info'
            }
        },
        // end - code coverage settings
        /*jshint camelcase: false */
        dom_munger: {
            annotated: {
                options: {
                    callback: function($) {
                        var container = $('#container');
                        $('html').replaceWith(container);
                        $('#container').html($('#container').html().replace('{{', '{ {'));
                    }
                },
                src: './docs/<%= pkg.name %>_lite.html',
                dest: './docs/annotated.html'
            }
        },
        /*jshint camelcase: true */
        bump: {
            options: {
                files: ['bower.json'],
                updateConfigs: ['bw'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['bower.json', 'CHANGELOG.md'],
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: '<%= bw.repository.url %>',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
                globalReplace: false,
                prereleaseName: false,
                regExp: false
            }
        },
        changelog: {
            options: {
                version: '<%= bw.version %>',
                repository: '<%= bw.repository.url %>'
            }
        },
    });

    grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function(target) {
        /*if (grunt.option('allow-remote')) {
            grunt.config.set('connect.options.hostname', '0.0.0.0');
        }*/
        if (target === 'lab') {
            return grunt.task.run(['build', 'browserSync:lab', 'watch']);
        }
        if (target === 'todo') {
            return grunt.task.run(['build', 'browserSync:todo', 'watch']);
        }

        grunt.task.run(['build', 'browserSync', 'watch']);

    });

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

    grunt.registerTask('test', function(target) {

        if (target === 'src') {
            return grunt.task.run(['mochaTest:src']);

        }
        if (target === 'examples') {
            return grunt.task.run(['mochaTest:tests']);

        }
        // Default all
        grunt.task.run([
            'build',
            'jshint:test',
            'mochaTest:tests'
        ]);
    });

    grunt.registerTask('coverage', [
        /*'jshint:test',*/
        'clean:coverage',
        'preprocess',
        'env:coverage',
        'instrument',
        'mochaTest:src',
        'storeCoverage',
        'makeReport'
    ]);

    grunt.registerTask('build', [
        'jshint:all',
        'clean:dist',
        'preprocess',
        'preprocess:lite',
        'concat',
        'docco',
        'wiredep'
    ]);

    grunt.registerTask('metrics', [
        'plato'
    ]);

    grunt.registerTask('_commit', [
        'changelog',
        'bump-commit'
    ]);

    grunt.registerTask('annotated', [
        'docco',
        'dom_munger'
    ]);

    grunt.registerTask('release', function(version) {
        var semVer = /\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b/ig;

        if (!semVer.test(version)) {
            grunt.option('setversion', false);
            grunt.task.run('bump-only:' + version);
        } else {
            grunt.option('setversion', version);
            grunt.task.run('bump-only');
        }

        grunt.task.run('_commit');
    });

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);
};
<commit_msg>Add grunt task for marionette backward compatibility<commit_after>//Skeleton GruntFile
// ------------------
'use strict';
/*globals require, module */

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

module.exports = function(grunt) {

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

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

    // Configurable paths
    var config = {
        src: 'src',
        build: 'src/build',
        dist: 'dist',
        test: 'test',
        examples: 'examples',
        docs: 'docs',
        bower: 'bower_components'
    };

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

        // Project settings
        config: config,
        pkg: grunt.file.readJSON('package.json'),

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= config.src %>/**/*.js', '<%= config.examples %>/**/*.js'],
                tasks: ['preprocess']
            },
            build: {
                files: ['<%= config.src %>/build/{,*/}*.js'],
            },
            jstest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['test:watch']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            }
        },
        // The actual grunt server settings
        browserSync: {
            options: {
                open: true,
                port: 9000,
                watchTask: true,
                server: {
                    files: ['<%= config.examples %>/**/*.js', '<%= config.src %>/**/*.js'],
                    baseDir: '<%= config.examples %>',
                    directory: true,
                    routes: {
                        '/bower_components': 'bower_components',
                        '/dist': 'dist'
                    }
                },
            },
            todo: {
                bsFiles: {
                    src: [
                        '<%= config.examples %>/todo/*.js',
                        '<%= config.examples %>/todo/*.html',
                        '<%= config.examples %>/todo/*.css',
                        '<%= config.dist %>/**/*.js'
                    ]
                },
                options: {
                    watchTask: true,
                    server: {
                        directory: false,
                        baseDir: '<%= config.examples %>/todo',
                        index: 'index.html',
                        routes: {
                            '/bower_components': 'bower_components',
                            '/dist': 'dist'
                        }
                    }
                }
            },
            lab: {
                bsFiles: {
                    src: [
                        '<%= config.examples %>/lab/*.js',
                        '<%= config.examples %>/lab/*.html',
                        '<%= config.examples %>/lab/*.css',
                        '<%= config.dist %>/**/*.js'
                    ]
                },
                options: {
                    watchTask: true,
                    server: {
                        directory: false,
                        baseDir: '<%= config.examples %>/lab',
                        index: 'index.html',
                        routes: {
                            '/bower_components': 'bower_components',
                            '/dist': 'dist'
                        }
                    }
                }

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

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: true,
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%= config.src %>{,*/}*.js',
                '!<%= config.examples %>{,*/}*.js',
                'test/unit/**/*.js'
            ],
            test: ['test/**/<%= pkg.name %>.js']
        },

        // Mocha testing framework configuration options
        mochaTest: {
            tests: {
                options: {
                    require: 'test/unit/setup/node.js',
                    reporter: grunt.option('mocha-reporter') || 'nyan',
                    clearRequireCache: true,
                    mocha: require('mocha')
                },
                src: [
                    'test/unit/setup/helpers.js',
                    'test/unit/jskeleton-src/*.spec.js',
                    'test/unit/marionette-comp/*.spec.js'
                ]
            },
            src: {
                options: {
                    require: 'test/unit/setup/node.js',
                    reporter: grunt.option('mocha-reporter') || 'nyan',
                    clearRequireCache: true,
                    mocha: require('mocha')
                },
                src: [
                    'test/unit/setup/helpers.js',
                    'test/unit/jskeleton-src/*.spec.js'
                ]
            },
            marionette: {
                options: {
                    require: 'test/unit/setup/node.js',
                    reporter: grunt.option('mocha-reporter') || 'nyan',
                    clearRequireCache: true,
                    mocha: require('mocha')
                },
                src: [
                    'test/unit/marionette-comp/*.spec.js'
                ]
            }
        },
        // Automatically inject Bower components into the HTML file
        wiredep: {
            task: {
                //ignorePath: /^\/|\.\.\//,
                src: ['<%= config.examples %>/**/*.html']
            },
            options: {

            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= config.dist %>/jskeleton.min.js': [
                        '<%= config.dist %>/jskeleton.js'
                    ]
                }
            }
        },
        concat: {
            options: {
                stripBanners: true,
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
                    '<%= grunt.template.today("yyyy-mm-dd") %> \n */'

            },
            dist: {
                src: [
                    '<%= config.dist %>/<%= pkg.name %>.js'
                ],
                dest: '<%= config.dist %>/<%= pkg.name %>.js'
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= config.src %>',
                    dest: '<%= config.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'styles/fonts/{,*/}*.*'
                    ]
                }, {
                    src: 'node_modules/apache-server-configs/dist/.htaccess',
                    dest: '<%= config.dist %>/.htaccess'
                }]
            },
            coverage: {
                expand: true,
                flatten: true,
                src: ['<%= config.dist %>/*.js'],
                dest: 'test/coverage/instrument/build'
            }
        },
        preprocess: {
            'default': {
                src: '<%= config.build %>/main.js',
                dest: '<%= config.dist %>/<%= pkg.name %>.js'
            },
            'lite': {
                src: '<%= config.build %>/main-lite.js',
                dest: '<%= config.dist %>/<%= pkg.name %>_lite.js'
            }
        },
        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [],
            test: [],
            dist: []
        },
        docco: {
            options: {
                dst: './docs',
                layout: 'parallel'
            },
            docs: {
                files: [{
                    expand: true,
                    cwd: '<%= config.dist %>',
                    src: [
                        '<%= pkg.name %>_lite.js',
                    ]
                }]
            }
        },
        env: {
            coverage: {
                APP_DIR_FOR_CODE_COVERAGE: '../../../test/src/'
            }
        },
        instrument: {
            files: 'src/**/*.js',
            options: {
                lazy: true,
                basePath: 'test'
            }
        },
        storeCoverage: {
            options: {
                dir: 'coverage'
            }
        },
        makeReport: {
            src: 'coverage/**/*.json',
            options: {
                type: 'lcov',
                dir: 'coverage',
                print: 'detail'
            }
        },
        plato: {
            report: {
                files: {
                    'metrics': ['src/**/*.js', 'test/**/*.js']
                }
            }
        },

        coveralls: {
            'default': {
                src: 'coverage/lcov.info'
            }
        },
        // end - code coverage settings
        /*jshint camelcase: false */
        dom_munger: {
            annotated: {
                options: {
                    callback: function($) {
                        var container = $('#container');
                        $('html').replaceWith(container);
                        $('#container').html($('#container').html().replace('{{', '{ {'));
                    }
                },
                src: './docs/<%= pkg.name %>_lite.html',
                dest: './docs/annotated.html'
            }
        },
        /*jshint camelcase: true */
        bump: {
            options: {
                files: ['bower.json'],
                updateConfigs: ['bw'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['bower.json', 'CHANGELOG.md'],
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: '<%= bw.repository.url %>',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
                globalReplace: false,
                prereleaseName: false,
                regExp: false
            }
        },
        changelog: {
            options: {
                version: '<%= bw.version %>',
                repository: '<%= bw.repository.url %>'
            }
        },
    });

    grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function(target) {
        /*if (grunt.option('allow-remote')) {
            grunt.config.set('connect.options.hostname', '0.0.0.0');
        }*/
        if (target === 'lab') {
            return grunt.task.run(['build', 'browserSync:lab', 'watch']);
        }
        if (target === 'todo') {
            return grunt.task.run(['build', 'browserSync:todo', 'watch']);
        }

        grunt.task.run(['build', 'browserSync', 'watch']);

    });

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

    grunt.registerTask('test', function(target) {

        grunt.task.run(['build']);

        if (target === 'src') {
            return grunt.task.run(['mochaTest:src']);
        }

        if (target === 'examples') {
            return grunt.task.run(['mochaTest:tests']);
        }

        if (target === 'examples') {
            return grunt.task.run(['mochaTest:marionette']);
        }

        // Default all
        grunt.task.run([
            'jshint:test',
            'mochaTest:tests'
        ]);
    });

    grunt.registerTask('coverage', [
        /*'jshint:test',*/
        'clean:coverage',
        'preprocess',
        'env:coverage',
        'instrument',
        'mochaTest:src',
        'storeCoverage',
        'makeReport'
    ]);

    grunt.registerTask('build', [
        'jshint:all',
        'clean:dist',
        'preprocess',
        'preprocess:lite',
        'concat',
        'docco',
        'wiredep'
    ]);

    grunt.registerTask('metrics', [
        'plato'
    ]);

    grunt.registerTask('_commit', [
        'changelog',
        'bump-commit'
    ]);

    grunt.registerTask('annotated', [
        'docco',
        'dom_munger'
    ]);

    grunt.registerTask('release', function(version) {
        var semVer = /\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b/ig;

        if (!semVer.test(version)) {
            grunt.option('setversion', false);
            grunt.task.run('bump-only:' + version);
        } else {
            grunt.option('setversion', version);
            grunt.task.run('bump-only');
        }

        grunt.task.run('_commit');
    });

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


<commit_before>/*global module:false*/
module.exports = function(grunt) {
    // Project configuration
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // JavaScript Minifier. Add your files to be minified in the src array.
        uglify: {
            build: {
                src: [
                    // 'res/js/boostrap.js',
                    'res/js/global.js',
                    'res/js/fitvids.js',
                    'res/js/fastclick.js'
                ],
                dest: 'res/build/global.min.js'
            }
        },
        // CSS Minifier. Add your files to be minified in the src array.
        cssmin: {
            build: {
                src: [
                    'res/css/bootstrap.css',
                    'res/css/font-awesome.css',
                    'res/css/typography.css',
                    'res/css/layout.css',
                    'res/css/prototype.css'
                ],
                dest: 'res/build/global.min.css'
            }
        },
        /* Compiles LESS files in res/less. Uses grunt's glob expansion to get everything in the dir.
         * You won't need to update this when you add a new file. */
        less: {
            boot: {
                    files: [
                    {
                        expand: true,
                        cwd: 'res/bootstrap/',
                        src: ['bootstrap.less'],
                        dest: 'res/css/',
                        ext: '.css'
                    }
                ]
            },
            dev: {
                    files: [
                    {
                        expand: true,
                        cwd: 'res/less/',
                        src: ['*.less'],
                        dest: 'res/css/',
                        ext: '.css'
                    }
                ]
            }
        },

        // Contains tasks to run when grunt watch is invoked. Whenever any of the files specified are modified, executes tasks specified.
        watch: {
            less: {
                files: 'res/less/*.less',
                tasks: 'less:dev'
            }
        }
    });

    // Load plugins. Run npm install in the theme root to install these according to package.json
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // Default task - executes when you run grunt in the theme root.
    grunt.registerTask('default', ['less:dev', 'uglify', 'cssmin']);
};<commit_msg>adding fastbutton to grunt<commit_after>/*global module:false*/
module.exports = function(grunt) {
    // Project configuration
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // JavaScript Minifier. Add your files to be minified in the src array.
        uglify: {
            build: {
                src: [
                    // 'res/js/boostrap.js',
                    'res/js/global.js',
                    'res/js/fitvids.js',
                    'res/js/google.fastbutton.js',
                    'res/js/jquery.google.fastbutton.js'
                ],
                dest: 'res/build/global.min.js'
            }
        },
        // CSS Minifier. Add your files to be minified in the src array.
        cssmin: {
            build: {
                src: [
                    'res/css/bootstrap.css',
                    'res/css/font-awesome.css',
                    'res/css/typography.css',
                    'res/css/layout.css',
                    'res/css/prototype.css'
                ],
                dest: 'res/build/global.min.css'
            }
        },
        /* Compiles LESS files in res/less. Uses grunt's glob expansion to get everything in the dir.
         * You won't need to update this when you add a new file. */
        less: {
            boot: {
                    files: [
                    {
                        expand: true,
                        cwd: 'res/bootstrap/',
                        src: ['bootstrap.less'],
                        dest: 'res/css/',
                        ext: '.css'
                    }
                ]
            },
            dev: {
                    files: [
                    {
                        expand: true,
                        cwd: 'res/less/',
                        src: ['*.less'],
                        dest: 'res/css/',
                        ext: '.css'
                    }
                ]
            }
        },

        // Contains tasks to run when grunt watch is invoked. Whenever any of the files specified are modified, executes tasks specified.
        watch: {
            less: {
                files: 'res/less/*.less',
                tasks: 'less:dev'
            }
        }
    });

    // Load plugins. Run npm install in the theme root to install these according to package.json
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // Default task - executes when you run grunt in the theme root.
    grunt.registerTask('default', ['less:dev', 'uglify', 'cssmin']);
};
<|endoftext|>


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

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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    less: {
      core: {
        options: {
          outputSourceFiles: true,
          sourceMap: true,
          sourceMapFilename: 'html/assets/app/css/style.css.map',
          sourceMapURL: 'style.css.map',
          strictMath: true
        }
        files: {
          'html/assets/app/css/style.css': 'less/style.less'
        }
      }
    },
    postcss: {
      options: {
        map: true,
        processors: [
          require('autoprefixer')
        ]
      }
    },
    csscomb: {
      options: {
        config: 'less/.csscomb.json'
      },
      core: {
        src: 'html/assets/app/css/style.css',
        dest: 'html/assets/app/css/style.css'
      }
    },
    csslint: {
      options: {
        csslintrc: 'less/.csslintrc'
      },
      core: {
        src: 'html/assets/app/css/style.css'
      }
    },
    cssmin: {
      options: {
        advanced: false,
        keepSpecialComments: '*',
        sourceMap: true
      },
      core: {
        expand: true,
        cwd: 'dist/assets/app/css',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/assets/app/css',
        ext: '.min.css'
      }
    },
    eslint: {
      options: {
        configFile: 'js/.eslintrc'
      },
      target: 'js/*.js'
    }
  });
};
<commit_msg>Added jscs config<commit_after>module.exports = function (grunt) {
  'use strict';

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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    less: {
      core: {
        options: {
          outputSourceFiles: true,
          sourceMap: true,
          sourceMapFilename: 'html/assets/app/css/style.css.map',
          sourceMapURL: 'style.css.map',
          strictMath: true
        }
        files: {
          'html/assets/app/css/style.css': 'less/style.less'
        }
      }
    },
    postcss: {
      options: {
        map: true,
        processors: [
          require('autoprefixer')
        ]
      }
    },
    csscomb: {
      options: {
        config: 'less/.csscomb.json'
      },
      core: {
        src: 'html/assets/app/css/style.css',
        dest: 'html/assets/app/css/style.css'
      }
    },
    csslint: {
      options: {
        csslintrc: 'less/.csslintrc'
      },
      core: {
        src: 'html/assets/app/css/style.css'
      }
    },
    cssmin: {
      options: {
        advanced: false,
        keepSpecialComments: '*',
        sourceMap: true
      },
      core: {
        expand: true,
        cwd: 'dist/assets/app/css',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/assets/app/css',
        ext: '.min.css'
      }
    },
    eslint: {
      options: {
        configFile: 'js/.eslintrc'
      },
      target: 'js/*.js'
    },
    jscs: {
      options: {
        config: 'js/.jscsrc'
      },
      grunt: {
        src: 'Gruntfile.js'
      },
      core: {
        src: 'js/*.js'
      }
    }
  });
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  var browsers = [{
    browserName: "chrome",
    platform: "OS X 10.8"
  }, {
    browserName: "chrome",
    platform: "XP"
  }, {
    browserName: "chrome",
    platform: "linux"
  }, {
    browserName: "firefox",
    version: "19",
    platform: "XP"
  }, {
    browserName: "safari",
    version: "6",
    platform: "OS X 10.8"
  }, {
    browserName: "opera",
    platform: "Windows 2008",
    version: "12"
// Tests pass on IE6, but a misc error is thrown. TODO: Sort out with SauceLabs
//  }, {
//    browserName: "internet explorer",
//    platform: "XP",
//    version: "6"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "7"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "8"
  }, {
    browserName: "internet explorer",
    platform: "VISTA",
    version: "9"
  }, {
    browserName: "internet explorer",
    platform: "WIN8",
    version: "10"
  }];

  grunt.initConfig({
    connect: {
      server: {
        options: {
          base: "",
          port: 9999
        }
      }
    },
    'saucelabs-jasmine': {
      all: {
        options: {
          urls: ["http://127.0.0.1:9999#runner"],
          tunnelTimeout: 5,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          browsers: browsers,
          testname: "pasta tests",
          tags: ["master"]
        }
      }
    },
    watch: {}
  });

  // Loading dependencies
  for (var key in grunt.file.readJSON("package.json").devDependencies) {
    if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
  }

  grunt.registerTask("dev", ["connect", "watch"]);
  grunt.registerTask("test", ["connect", "saucelabs-jasmine"]);
};
<commit_msg>Fix runner url #9<commit_after>module.exports = function(grunt) {
  var browsers = [{
    browserName: "chrome",
    platform: "OS X 10.8"
  }, {
    browserName: "chrome",
    platform: "XP"
  }, {
    browserName: "chrome",
    platform: "linux"
  }, {
    browserName: "firefox",
    version: "19",
    platform: "XP"
  }, {
    browserName: "safari",
    version: "6",
    platform: "OS X 10.8"
  }, {
    browserName: "opera",
    platform: "Windows 2008",
    version: "12"
// Tests pass on IE6, but a misc error is thrown. TODO: Sort out with SauceLabs
//  }, {
//    browserName: "internet explorer",
//    platform: "XP",
//    version: "6"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "7"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "8"
  }, {
    browserName: "internet explorer",
    platform: "VISTA",
    version: "9"
  }, {
    browserName: "internet explorer",
    platform: "WIN8",
    version: "10"
  }];

  grunt.initConfig({
    connect: {
      server: {
        options: {
          base: "",
          port: 9999
        }
      }
    },
    'saucelabs-jasmine': {
      all: {
        options: {
          urls: ["http://127.0.0.1:9999/#runner"],
          tunnelTimeout: 5,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          browsers: browsers,
          testname: "pasta tests",
          tags: ["master"]
        }
      }
    },
    watch: {}
  });

  // Loading dependencies
  for (var key in grunt.file.readJSON("package.json").devDependencies) {
    if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
  }

  grunt.registerTask("dev", ["connect", "watch"]);
  grunt.registerTask("test", ["connect", "saucelabs-jasmine"]);
};
<|endoftext|>


<commit_before>// Generated on 2014-07-19 using generator-angular 0.7.1
'use strict';

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

module.exports = function (grunt) {

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

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

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

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      sass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.scss'],
        tasks: ['sass', 'newer:copy:styles', 'autoprefixer']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

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

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

    // compile sass files lightening fast with libSass
    sass: {
      dist: {
        files: {
          '<%= yeoman.app %>/styles/main.css': '<%= yeoman.app %>/styles/main.scss'
        }
      }
    },

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

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

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

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

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

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

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

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

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

    // Push build files from dist folder to gh-pages branch on github
    buildcontrol: {
      options: {
        dir: 'dist',
        commit: true,
        push: true,
        message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
      },
      pages: {
        options: {
          remote: 'git://github.com/tgdev/popvinyls.git',
          branch: 'gh-pages'
        }
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      dist: [
        'sass',
        'imagemin',
        'svgmin'
      ]
    },

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

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

    grunt.task.run([
      'clean:server',
      'bower-install',
      'sass',
      'copy:styles',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

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

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

  grunt.registerTask('deploy', [
    'build',
    'buildcontrol:pages'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Fixed path to remote in buildcontrol task<commit_after>// Generated on 2014-07-19 using generator-angular 0.7.1
'use strict';

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

module.exports = function (grunt) {

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

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

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

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      sass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.scss'],
        tasks: ['sass', 'newer:copy:styles', 'autoprefixer']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

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

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

    // compile sass files lightening fast with libSass
    sass: {
      dist: {
        files: {
          '<%= yeoman.app %>/styles/main.css': '<%= yeoman.app %>/styles/main.scss'
        }
      }
    },

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

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

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

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

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

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

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

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

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

    // Push build files from dist folder to gh-pages branch on github
    buildcontrol: {
      options: {
        dir: 'dist',
        commit: true,
        push: true,
        message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
      },
      pages: {
        options: {
          remote: 'https://github.com/tgdev/popvinyls.git',
          branch: 'gh-pages'
        }
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      dist: [
        'sass',
        'imagemin',
        'svgmin'
      ]
    },

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

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

    grunt.task.run([
      'clean:server',
      'bower-install',
      'sass',
      'copy:styles',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

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

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

  grunt.registerTask('deploy', [
    'build',
    'buildcontrol:pages'
  ]);

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


<commit_before>// Todo :
// - svgmin / svg rasterize
// - improve the generated stylesheet
// - concatening the generated stylesheet to a user stylesheet
// - deciding about a build system for markdown content

module.exports = function(grunt) {

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({

    clean: {
      //nettoyer les répertoires de build
      dev: ["www/**/*.*"],
      dist: ["dist/**/*.*"]
      // fonts: ['www/fonts/**/*.*'],
      // images_all: ['www/images/**/*.*'],
      // images_svg: ['www/images/**/*.svg'],
      // css: ['www/css/**/*.*'],
      // html: ['www/**/*.html']
    },

    copy: {
      images_dev: {
        expand: true,
        cwd: 'documents/images/',
        src: '**',
        dest: 'www/images/',
        flatten: true,
        filter: 'isFile'
      },
      images_dist: {
        expand: true,
        cwd: 'documents/images/',
        src: '**',
        dest: 'dist/images/',
        flatten: true,
        filter: 'isFile'
      },
      css_dev: {
        expand: true,
        cwd: 'documents/css',
        src: '**',
        dest: 'www/css/',
        flatten: true,
        filter: 'isFile'
      },
      css_dist: {
        expand: true,
        cwd: 'documents/css',
        src: '**',
        dest: 'dist/css/',
        flatten: true,
        filter: 'isFile'
      }
    },

    // linting js avec reporter ameliore
    jshint: {
      options: {
        reporter: require('jshint-stylish')
      },
      //vérification du gruntfile
      gruntfile: {
        src: ['Gruntfile.js']
      }
    },

    /**** Tâches de conversion SVG -> webfonts **************/
    icons2fonts: {
      dev: {},
      dist: {}
    },

    svgicons2svgfont: {
      options: {
        font: 'iconsfont',
        appendCodepoints: true
      },
      dev: {
        src: 'documents/icons/*.svg',
        dest: 'www/fonts'
      },
      dist: {
        src: 'documents/icons/*.svg',
        dest: 'dist/fonts'
      }
    },

    svg2ttf: {
      dev: {
        src: 'www/fonts/*.svg',
        dest: 'www/fonts'
      },
      dist: {
        src: 'dist/fonts/*.svg',
        dest: 'dist/fonts'
      }
    },

    ttf2eot: {
      dev: {
        src: 'www/fonts/*.ttf',
        dest: 'www/fonts'
      },
      dist: {
        src: 'dist/fonts/*.ttf',
        dest: 'dist/fonts'
      }
    },

    ttf2woff: {
      dev: {
        src: 'www/fonts/*.ttf',
        dest: 'www/fonts'
      },
      dist: {
        src: 'dist/fonts/*.ttf',
        dest: 'dist/fonts'
      }
    },

    /* Compilation Less */
    less: {
      dev: {
        src: 'documents/less/main.less',
        dest: 'www/css/pictofont.css'
      },
      dist: {
        src: 'documents/less/main.less',
        dest: 'dist/css/pictofont.css'
      }
    },

    cssmin: {
      dist: {
        expand: true,
        cwd: 'dist/css/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/css/',
        ext: '.min.css'
      }
    },

    imagemin: {
      dev: {
        options: {
          optimizationLevel: 3
        },
        expand: true,
        cwd: 'documents/images',
        src: ['**/*.{png,gif,jpg}'],
        dest: 'www/images/'
      },
      dist: {
        options: {
          optimizationLevel: 3
        },
        expand: true,
        cwd: 'documents/images',
        src: ['**/*.{png,gif,jpg}'],
        dest: 'dist/images/'
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: 'documents/images',
          src: ['**/*.svg'],
          dest: 'dist/images/',
          ext: '.svg'
        }]
      }
    },

    browserify: {
      frontend: {
        src: 'src/frontend.js',
        dest: 'www/javascript/script.js',
        options: {
          standalone: 'chtijs'
        }
      }
    },
    /* Serveur pour le livereload */
    connect: {
      livereload: {
        options: {
          port: 9001,
          // Change hostname to '0.0.0.0' to access
          // the server from outside.
          hostname: 'localhost',
          base: 'www/',
          open: true,
          livereload: true
        }
      }
    },

    /*
      Surveiller les fichiers, si changement, retraitement
      et reload automatique du navigateur
    */
    watch: {
      options: {
        livereload: true
      },
      icons: {
        files: ['documents/icons/*.svg'],
        tasks: ['icons2fonts:dev']
      },
      less: {
        files: ['documents/less/*.less'],
        tasks: ['less:main']
      },
      svgimages: {
        files: ['documents/images/*.svg'],
        tasks: ['svgmin:dist']
      },
      bitmapimages: {
        files: ['documents/images/*.{png,gif,jpg}'],
        tasks: ['imagemin:dist']
      },
      css: {
        files: ['www/css/*.css', '!www/css/pictofont.css'] //on ramasse les CSS, mais on exclut les fichiers générés par la tâche less
      },
      content: {
        files: ['documents/contenu/**/*.md'],
        tasks: ['build_content']
      },
      templates: {
        files: ['documents/templates/**/*.tpl']
      },
      frontscripts: {
        files: ['src/frontend.js', 'src/front/**/*.js'],
        tasks: ['browserify:frontend']
      },
      backscripts: {
        files: ['src/backend.js', 'src/back/**/*.js']
      }
    },
    build_content: {
      options: {
        base_url: ""
      },
      dev: {
        expand: true,
        cwd: 'documents/contenu',
        src: ['**/*.md'],
        dest: 'www/',
        ext: '.html'
      },
      dist: {
        expand: true,
        cwd: 'documents/contenu',
        src: ['**/*.md'],
        dest: 'dist/',
        ext: '.html',
        options: {
          base_url: "http://smdlsld.fr"
        }
      }
    }
  });

  grunt.registerMultiTask('icons2fonts', 'Converts svg icons to webfonts', function() {
    var targetStr = "";
    if (this.target) {
      targetStr = ":" + this.target;
    }
    grunt.task.run([
      'svgicons2svgfont' + targetStr,
      'svg2ttf' + targetStr,
      'ttf2eot' + targetStr,
      'ttf2woff' + targetStr
    ]);
  });

  grunt.registerTask('dev', 'Run website locally and start watch process (living document).', function() {
    grunt.task.run('clean:dev');
    grunt.file.mkdir('./www/images');
    grunt.file.mkdir('./www/fonts');
    grunt.file.mkdir('./www/css');
    grunt.file.mkdir('./www/js');
    grunt.task.run([
      'icons2fonts:dev',
      'less:dev',
      'copy:images_dev',
      'copy:css_dev',
      'build_content:dev',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('dist', 'Build the website ready for production', function() {
    grunt.task.run('clean:dist');
    grunt.file.mkdir('./dist/images');
    grunt.file.mkdir('./dist/fonts');
    grunt.file.mkdir('./dist/css');
    grunt.file.mkdir('./dist/js');
    grunt.task.run([
      'icons2fonts:dist',
      'less:dist',
      'copy:css_dist',
      'cssmin:dist',
      'imagemin:dist',
      'svgmin:dist',
      'build_content:dist'
    ]);
  });

  grunt.registerTask('default', [
    'jshint:gruntfile'
  ]);

  /* HTML page builder */
  grunt.registerMultiTask('build_content', 'build the website html pages', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      base_url: grunt.option('base_url') ? grunt.option('base_url') : ""
    });

    //chargeur et convertisseur de fichiers markdown
    var marked = require('marked');

    //moteur de templates
    var nunjucks = require('nunjucks');
    nunjucks.configure('documents/templates/', {
      autoescape: true
    });

    //charger les metadata du site
    //var metadata_site =;

    //pour chaque fichier ramassé par la configuration
    this.files.forEach(function(file) {
      //convertir le mardown en html
      var html = marked(grunt.file.read(file.src));

      // transmettre le tout aux templates
      var finalHtml = nunjucks.render('index.tpl', {
        env: grunt.task.target,
        content: html,
        metadata: {}, //TODO
        metadata_site: options
      });

      // écrire le fichier
      grunt.file.write(file.dest, finalHtml);

      // Print a success message.
      grunt.log.writeln('File "' + file.dest + '" created.');
    });
  });

};<commit_msg>Rendre le gruntfile plus lisible<commit_after>// Todo :
// - svgmin / svg rasterize
// - improve the generated stylesheet
// - concatening the generated stylesheet to a user stylesheet

module.exports = function(grunt) {

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.registerMultiTask('icons2fonts', 'Converts svg icons to webfonts', function() {
    var targetStr = "";
    if (this.target) {
      targetStr = ":" + this.target;
    }
    grunt.task.run([
      'svgicons2svgfont' + targetStr,
      'svg2ttf' + targetStr,
      'ttf2eot' + targetStr,
      'ttf2woff' + targetStr
    ]);
  });

  grunt.registerTask('dev', 'Run website locally and start watch process (living document).', function() {

    grunt.task.run('clean:dev');

    grunt.file.mkdir('./www/images');
    grunt.file.mkdir('./www/fonts');
    grunt.file.mkdir('./www/css');
    grunt.file.mkdir('./www/js');

    grunt.task.run([
      'icons2fonts:dev',
      'less:dev',
      'copy:images_dev',
      'copy:css_dev',
      'build_content:dev',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('dist', 'Build the website ready for production', function() {

    grunt.task.run('clean:dist');

    grunt.file.mkdir('./dist/images');
    grunt.file.mkdir('./dist/fonts');
    grunt.file.mkdir('./dist/css');
    grunt.file.mkdir('./dist/js');

    grunt.task.run([
      'icons2fonts:dist',
      'less:dist',
      'copy:css_dist',
      'cssmin:dist',
      'imagemin:dist',
      'svgmin:dist',
      'build_content:dist'
    ]);
  });

  grunt.registerTask('default', [
    'jshint:gruntfile'
  ]);

  /* HTML page builder */
  grunt.registerMultiTask('build_content', 'build the website html pages', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      base_url: grunt.option('base_url') ? grunt.option('base_url') : ""
    });

    //chargeur et convertisseur de fichiers markdown
    var marked = require('marked');

    //moteur de templates
    var nunjucks = require('nunjucks');
    nunjucks.configure('documents/templates/', {
      autoescape: true
    });

    //charger les metadata du site
    //var metadata_site =;

    //pour chaque fichier ramassé par la configuration
    this.files.forEach(function(file) {
      //convertir le mardown en html
      var html = marked(grunt.file.read(file.src));

      // transmettre le tout aux templates
      var finalHtml = nunjucks.render('index.tpl', {
        env: grunt.task.target,
        content: html,
        metadata: {}, //TODO
        metadata_site: options
      });

      // écrire le fichier
      grunt.file.write(file.dest, finalHtml);

      // Print a success message.
      grunt.log.writeln('File "' + file.dest + '" created.');
    });
  });

  grunt.initConfig({

    clean: {
      //nettoyer les répertoires de build
      dev: ["www/**/*.*"],
      dist: ["dist/**/*.*"]
      // fonts: ['www/fonts/**/*.*'],
      // images_all: ['www/images/**/*.*'],
      // images_svg: ['www/images/**/*.svg'],
      // css: ['www/css/**/*.*'],
      // html: ['www/**/*.html']
    },

    copy: {
      images_dev: {
        expand: true,
        cwd: 'documents/images/',
        src: '**',
        dest: 'www/images/',
        flatten: true,
        filter: 'isFile'
      },
      images_dist: {
        expand: true,
        cwd: 'documents/images/',
        src: '**',
        dest: 'dist/images/',
        flatten: true,
        filter: 'isFile'
      },
      css_dev: {
        expand: true,
        cwd: 'documents/css',
        src: '**',
        dest: 'www/css/',
        flatten: true,
        filter: 'isFile'
      },
      css_dist: {
        expand: true,
        cwd: 'documents/css',
        src: '**',
        dest: 'dist/css/',
        flatten: true,
        filter: 'isFile'
      }
    },

    // linting js avec reporter ameliore
    jshint: {
      options: {
        reporter: require('jshint-stylish')
      },
      //vérification du gruntfile
      gruntfile: {
        src: ['Gruntfile.js']
      }
    },

    /**** Tâches de conversion SVG -> webfonts **************/
    icons2fonts: {
      dev: {},
      dist: {}
    },

    svgicons2svgfont: {
      options: {
        font: 'iconsfont',
        appendCodepoints: true
      },
      dev: {
        src: 'documents/icons/*.svg',
        dest: 'www/fonts'
      },
      dist: {
        src: 'documents/icons/*.svg',
        dest: 'dist/fonts'
      }
    },

    svg2ttf: {
      dev: {
        src: 'www/fonts/*.svg',
        dest: 'www/fonts'
      },
      dist: {
        src: 'dist/fonts/*.svg',
        dest: 'dist/fonts'
      }
    },

    ttf2eot: {
      dev: {
        src: 'www/fonts/*.ttf',
        dest: 'www/fonts'
      },
      dist: {
        src: 'dist/fonts/*.ttf',
        dest: 'dist/fonts'
      }
    },

    ttf2woff: {
      dev: {
        src: 'www/fonts/*.ttf',
        dest: 'www/fonts'
      },
      dist: {
        src: 'dist/fonts/*.ttf',
        dest: 'dist/fonts'
      }
    },

    /* Compilation Less */
    less: {
      dev: {
        src: 'documents/less/main.less',
        dest: 'www/css/pictofont.css'
      },
      dist: {
        src: 'documents/less/main.less',
        dest: 'dist/css/pictofont.css'
      }
    },

    cssmin: {
      dist: {
        expand: true,
        cwd: 'dist/css/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/css/',
        ext: '.min.css'
      }
    },

    imagemin: {
      dev: {
        options: {
          optimizationLevel: 3
        },
        expand: true,
        cwd: 'documents/images',
        src: ['**/*.{png,gif,jpg}'],
        dest: 'www/images/'
      },
      dist: {
        options: {
          optimizationLevel: 3
        },
        expand: true,
        cwd: 'documents/images',
        src: ['**/*.{png,gif,jpg}'],
        dest: 'dist/images/'
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: 'documents/images',
          src: ['**/*.svg'],
          dest: 'dist/images/',
          ext: '.svg'
        }]
      }
    },

    browserify: {
      frontend: {
        src: 'src/frontend.js',
        dest: 'www/javascript/script.js',
        options: {
          standalone: 'chtijs'
        }
      }
    },
    /* Serveur pour le livereload */
    connect: {
      livereload: {
        options: {
          port: 9001,
          // Change hostname to '0.0.0.0' to access
          // the server from outside.
          hostname: 'localhost',
          base: 'www/',
          open: true,
          livereload: true
        }
      }
    },

    /*
      Surveiller les fichiers, si changement, retraitement
      et reload automatique du navigateur
    */
    watch: {
      options: {
        livereload: true
      },
      icons: {
        files: ['documents/icons/*.svg'],
        tasks: ['icons2fonts:dev']
      },
      less: {
        files: ['documents/less/*.less'],
        tasks: ['less:main']
      },
      svgimages: {
        files: ['documents/images/*.svg'],
        tasks: ['svgmin:dist']
      },
      bitmapimages: {
        files: ['documents/images/*.{png,gif,jpg}'],
        tasks: ['imagemin:dist']
      },
      css: {
        files: ['www/css/*.css', '!www/css/pictofont.css'] //on ramasse les CSS, mais on exclut les fichiers générés par la tâche less
      },
      content: {
        files: ['documents/contenu/**/*.md'],
        tasks: ['build_content']
      },
      templates: {
        files: ['documents/templates/**/*.tpl']
      },
      frontscripts: {
        files: ['src/frontend.js', 'src/front/**/*.js'],
        tasks: ['browserify:frontend']
      },
      backscripts: {
        files: ['src/backend.js', 'src/back/**/*.js']
      }
    },
    build_content: {
      options: {
        base_url: ""
      },
      dev: {
        expand: true,
        cwd: 'documents/contenu',
        src: ['**/*.md'],
        dest: 'www/',
        ext: '.html'
      },
      dist: {
        expand: true,
        cwd: 'documents/contenu',
        src: ['**/*.md'],
        dest: 'dist/',
        ext: '.html',
        options: {
          base_url: "http://smdlsld.fr"
        }
      }
    }
  });
};<|endoftext|>


<commit_before>'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

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

  // Define paths
  var pathsConfig = {
    source: '.',
    destination: 'public'
  };

  grunt.initConfig({
    paths: pathsConfig,
    watch: {
      emberTemplates: {
        files: ['<%= paths.source %>/scripts/templates/**/*.handlebars'],
        tasks: ['emberTemplates']
      },
      coffee: {
        files: ['<%= paths.source %>/scripts/*.coffee'],
        tasks: ['coffee:dist']
      },
      coffeeTest: {
        files: ['test/spec/*.coffee'],
        tasks: ['coffee:test']
      },
      less: {
        files: ['<%= paths.source %>/styles/*.less', '<%= paths.source %>/styles/theme/*.less'],
        tasks: ['less']
      },
      livereload: {
        port: 8889,
        files: [
          '<%= paths.source %>/*.html',
          '{.tmp,<%= paths.source %>}/styles/*.css',
          '{.tmp,<%= paths.source %>}/scripts/*.js',
          '<%= paths.source %>/images/*.{png,jpg,jpeg}'
        ],
        tasks: ['livereload']
      }
    },
    livereload: {
      port: 8889
    },
    connect: {
      options: {
        hostname: null,
        port: 8000
      },
      livereload: {
        options: {
          middleware: function (connect, options) {
            return [
              function (req, res, next) {
                console.log(req.method, req.url);
                if (req.method === 'POST') {
                //if (req.originalUrl == '/api/v1/nodes.json' && req.method === 'GET') {
                  res.writeHead(404, {'Content-Type': 'application/json'});
                  res.end(JSON.stringify({'errors': {'name': 'Invalid parameter'}}));
                } else {
                  res.setHeader('Access-Control-Allow-Origin', '*');
                  res.setHeader('Access-Control-Allow-Methods', '*');
                  res.setHeader('Access-Control-Allow-Headers', 'Content-Type, X-CSRF-Token');
                  next();
                }
              },
              lrSnippet,
              mountFolder(connect, '.tmp'),
              mountFolder(connect, pathsConfig.source),
              connect.static(options.base),     // Serve static files
              connect.directory(options.base)   // Make empty directories browsable,

            ];
          }
        }
      },
      test: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, '.tmp'),
              mountFolder(connect, 'test')
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, pathsConfig.destination)
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    clean: {
      temp: ['.tmp', '<%= paths.source %>/styles/theme.css', '<%= paths.source %>/scripts/templates.js'],
      public: {
        options: {
          force: true
        },
        src: ['../<%= paths.destination %>']  // This clean path should match the last copy path (one dir up)
      },
      dist: ['.tmp', '<%= paths.destination %>', '<%= paths.source %>/styles/theme.css', '<%= paths.source %>/scripts/templates.js'],
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= paths.source %>/scripts/*.js',
        'test/spec/*.js'
      ]
    },
    emberTemplates: {
      options: {
        templateName: function (sourceFile) {
          return sourceFile.replace(pathsConfig.source + '/scripts/templates/', '');
        }
      },
      server: {
        files: {
          '.tmp/scripts/templates.js': ['<%= paths.source %>/scripts/templates/**/*.handlebars']
        }
      },
      dist: {
        files: {
          '<%= paths.source %>/scripts/templates.js': ['<%= paths.source %>/scripts/templates/**/*.handlebars']
        }
      }
    },
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://localhost:<%= connect.options.port %>/index.html']
        }
      }
    },
    coffee: {
      dist: {
        files: {
          '.tmp/scripts/coffee.js': '<%= paths.source %>/scripts/*.coffee'
        }
      },
      test: {
        files: [{
          expand: true,
          cwd: '.tmp/spec',
          src: '*.coffee',
          dest: 'test/spec'
        }]
      }
    },
    less: {
      options: {
        paths: ['<%= paths.source %>/styles']
      },
      server: {
        files: {
          '.tmp/styles/theme.css': '<%= paths.source %>/styles/theme.less'
        }
      },
      dist: {
        files: {
          '<%= paths.source %>/styles/theme.css': '<%= paths.source %>/styles/theme.less'
        }
      },
      debug: {
        files: {
          '<%= paths.destination %>/styles/theme.css': '<%= paths.source %>/styles/theme.less'
        }
      }
    },
    concat: {
      dist: {}
    },
    uglify: {
      dist: {
        files: {
          '<%= paths.destination %>/scripts/main.js': [
            '.tmp/scripts/*.js',
            '<%= paths.source %>/scripts/*.js'
          ]
        }
      }
    },
    useminPrepare: {
      html: '<%= paths.source %>/index.html',
      options: {
        dest: '<%= paths.destination %>'
      }
    },
    usemin: {
      html: ['<%= paths.destination %>/*.html'],
      css: ['<%= paths.destination %>/styles/*.css'],
      options: {
        dirs: ['.tmp', '<%= paths.destination %>']
      }
    },
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= paths.source %>/images/',
          dest: '<%= paths.destination %>/images/',
          src: [
            '*.{png,jpg}'
          ]
        }]
      }
    },
    cssmin: {
      options: {
        keepSpecialComments: 0
      },
      dist: {
        files: {
          '<%= paths.destination %>/styles/main.css': '<%= paths.destination %>/styles/main.css'
        }
      }
    },
    htmlmin: {
      dist: {
        options: {
        /*removeCommentsFromCDATA: true,
        // https://github.com/paths.grunt-usemin/issues/44
        //collapseWhitespace: true,
        collapseBooleanAttributes: true,
        removeAttributeQuotes: true,
        removeRedundantAttributes: true,
        useShortDoctype: true,
        removeEmptyAttributes: true,
        removeOptionalTags: true*/
        },
        files: [{
          expand: true,
          cwd: '<%= paths.source %>',
          src: '*.html',
          dest: '<%= paths.destination %>'
        }]
      }
    },
    copy: {
      js: {
        files: [{
          expand: true,
          flatten: false,
          cwd: '<%= paths.source %>/scripts/',
          src: ['main.js', '**/*.js'],
          dest: '<%= paths.destination %>/scripts/'
        }]
      },
      components: {
        files: [{
          expand: true,
          flatten: false,
          cwd: '<%= paths.source %>/components/',
          src: ['**/*.js', '**/*.css'],
          dest: '<%= paths.destination %>/components/'
        }]
      },
      images: {
        files: [{
          expand: true,
          cwd: '<%= paths.source %>/images/',
          src: ['**', '!pastel/**'],
          dest: '<%= paths.destination %>/images/'
        }]
      },
      fonts: {
        files: [{
          expand: true,
          cwd: '<%= paths.source %>/font/',
          src: '**',
          dest: '<%= paths.destination %>/font/'
        }, {
          expand: true,
          cwd: '<%= paths.source %>/components/font-awesome/font/',
          src: '**',
          dest: '<%= paths.destination %>/font/'
        }]
      },
      project: {
        files: [{
          cwd: '<%= paths.source %>',
          src: ['*.{ico,txt}', '.htaccess'],
          dest: '<%= paths.destination %>',
          expand: true,
          dot: true
        }]
      },
      dist: {
        files: [{
          src: '<%= paths.destination %>/**',
          dest: '../',  // This copy path should match the clean path (one dir up)
          expand: true,
          dot: true
        }]
      }
    },
    bower: {
      rjsConfig: '<%= paths.source %>/scripts/main.js',
      indent: '  '
    }
  });

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

    grunt.task.run([
      'clean:temp',
      'emberTemplates:server',
      'less:server',
      'livereload-start',
      'connect:livereload',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('cleanup', [
    'clean:temp'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    //'jshint',
    //'test',
    'emberTemplates:dist',
    'less:dist',
    'useminPrepare',
    //'imagemin',
    'htmlmin',
    'concat',
    'uglify',
    'usemin',
    'cssmin',
    'clean:public',
    'copy:images',
    'copy:fonts',
    'copy:project',
    'copy:dist',
    'clean:dist'
  ]);

  grunt.registerTask('build-lite', [
    'clean:dist',
    //'jshint',
    //'test',
    'emberTemplates:dist',
    'less:dist',
    'useminPrepare',
    //'imagemin',
    'htmlmin',
    'concat',
    //'uglify',
    'usemin',
    //'cssmin',
    'clean:public',
    'copy:images',
    'copy:fonts',
    'copy:project',
    'copy:dist',
    'clean:dist'
  ]);

  grunt.registerTask('build-debug', [
    'clean:dist',
    'jshint',
    //'test',
    'emberTemplates:dist',
    'less:debug',
    //'useminPrepare',
    //'imagemin',
    'htmlmin',
    'concat',
    //'uglify',
    //'usemin',
    //'cssmin',
    'clean:public',
    'copy',
    'clean:dist'
  ]);

  /*
   * Run "grunt scrape --server=127.0.0.1" from the command line
   */
  grunt.registerTask('scrape', 'Download JSON files from API', function () {
    var path = require('path');
    var fs = require('fs');
    var http = require('http');
    var request = require('request');
    var mkpath = require('mkpath');
    var done = this.async();

    var server = grunt.option('server') || 'localhost';
    var jsonFiles = [
      '/api/v1/nodes.json',
      '/api/v1/vms.json'
    ];

    jsonFiles.forEach(function (jsonFile) {
      var requestUrl = 'http://' + server + jsonFile;
      var absolutePath = __dirname + jsonFile.split('/').join(path.sep);
      request(requestUrl, function (error, response, body) {
        if (!error && response.statusCode === 200) {
          mkpath.sync(absolutePath.split(path.sep).slice(0, -1).join(path.sep));
          var beautifiedJson = JSON.stringify(JSON.parse(body), null, 2);
          fs.writeFile(absolutePath, beautifiedJson);
        }
      });
      //request(requestUrl).pipe(fs.createWriteStream(absolutePath));
    });

  });

  grunt.registerTask('default', ['build']);
};
<commit_msg>Update scraping tool to parse JSON get_all responses and then download the individual get_one responses as well<commit_after>'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

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

  // Define paths
  var pathsConfig = {
    source: '.',
    destination: 'public'
  };

  grunt.initConfig({
    paths: pathsConfig,
    watch: {
      emberTemplates: {
        files: ['<%= paths.source %>/scripts/templates/**/*.handlebars'],
        tasks: ['emberTemplates']
      },
      coffee: {
        files: ['<%= paths.source %>/scripts/*.coffee'],
        tasks: ['coffee:dist']
      },
      coffeeTest: {
        files: ['test/spec/*.coffee'],
        tasks: ['coffee:test']
      },
      less: {
        files: ['<%= paths.source %>/styles/*.less', '<%= paths.source %>/styles/theme/*.less'],
        tasks: ['less']
      },
      livereload: {
        port: 8889,
        files: [
          '<%= paths.source %>/*.html',
          '{.tmp,<%= paths.source %>}/styles/*.css',
          '{.tmp,<%= paths.source %>}/scripts/*.js',
          '<%= paths.source %>/images/*.{png,jpg,jpeg}'
        ],
        tasks: ['livereload']
      }
    },
    livereload: {
      port: 8889
    },
    connect: {
      options: {
        hostname: null,
        port: 8000
      },
      livereload: {
        options: {
          middleware: function (connect, options) {
            return [
              function (req, res, next) {
                console.log(req.method, req.url);
                if (req.method === 'POST') {
                //if (req.originalUrl == '/api/v1/nodes.json' && req.method === 'GET') {
                  res.writeHead(404, {'Content-Type': 'application/json'});
                  res.end(JSON.stringify({'errors': {'name': 'Invalid parameter'}}));
                } else {
                  res.setHeader('Access-Control-Allow-Origin', '*');
                  res.setHeader('Access-Control-Allow-Methods', '*');
                  res.setHeader('Access-Control-Allow-Headers', 'Content-Type, X-CSRF-Token');
                  next();
                }
              },
              lrSnippet,
              mountFolder(connect, '.tmp'),
              mountFolder(connect, pathsConfig.source),
              connect.static(options.base),     // Serve static files
              connect.directory(options.base)   // Make empty directories browsable,

            ];
          }
        }
      },
      test: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, '.tmp'),
              mountFolder(connect, 'test')
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, pathsConfig.destination)
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    clean: {
      temp: ['.tmp', '<%= paths.source %>/styles/theme.css', '<%= paths.source %>/scripts/templates.js'],
      public: {
        options: {
          force: true
        },
        src: ['../<%= paths.destination %>']  // This clean path should match the last copy path (one dir up)
      },
      dist: ['.tmp', '<%= paths.destination %>', '<%= paths.source %>/styles/theme.css', '<%= paths.source %>/scripts/templates.js'],
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= paths.source %>/scripts/*.js',
        'test/spec/*.js'
      ]
    },
    emberTemplates: {
      options: {
        templateName: function (sourceFile) {
          return sourceFile.replace(pathsConfig.source + '/scripts/templates/', '');
        }
      },
      server: {
        files: {
          '.tmp/scripts/templates.js': ['<%= paths.source %>/scripts/templates/**/*.handlebars']
        }
      },
      dist: {
        files: {
          '<%= paths.source %>/scripts/templates.js': ['<%= paths.source %>/scripts/templates/**/*.handlebars']
        }
      }
    },
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://localhost:<%= connect.options.port %>/index.html']
        }
      }
    },
    coffee: {
      dist: {
        files: {
          '.tmp/scripts/coffee.js': '<%= paths.source %>/scripts/*.coffee'
        }
      },
      test: {
        files: [{
          expand: true,
          cwd: '.tmp/spec',
          src: '*.coffee',
          dest: 'test/spec'
        }]
      }
    },
    less: {
      options: {
        paths: ['<%= paths.source %>/styles']
      },
      server: {
        files: {
          '.tmp/styles/theme.css': '<%= paths.source %>/styles/theme.less'
        }
      },
      dist: {
        files: {
          '<%= paths.source %>/styles/theme.css': '<%= paths.source %>/styles/theme.less'
        }
      },
      debug: {
        files: {
          '<%= paths.destination %>/styles/theme.css': '<%= paths.source %>/styles/theme.less'
        }
      }
    },
    concat: {
      dist: {}
    },
    uglify: {
      dist: {
        files: {
          '<%= paths.destination %>/scripts/main.js': [
            '.tmp/scripts/*.js',
            '<%= paths.source %>/scripts/*.js'
          ]
        }
      }
    },
    useminPrepare: {
      html: '<%= paths.source %>/index.html',
      options: {
        dest: '<%= paths.destination %>'
      }
    },
    usemin: {
      html: ['<%= paths.destination %>/*.html'],
      css: ['<%= paths.destination %>/styles/*.css'],
      options: {
        dirs: ['.tmp', '<%= paths.destination %>']
      }
    },
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= paths.source %>/images/',
          dest: '<%= paths.destination %>/images/',
          src: [
            '*.{png,jpg}'
          ]
        }]
      }
    },
    cssmin: {
      options: {
        keepSpecialComments: 0
      },
      dist: {
        files: {
          '<%= paths.destination %>/styles/main.css': '<%= paths.destination %>/styles/main.css'
        }
      }
    },
    htmlmin: {
      dist: {
        options: {
        /*removeCommentsFromCDATA: true,
        // https://github.com/paths.grunt-usemin/issues/44
        //collapseWhitespace: true,
        collapseBooleanAttributes: true,
        removeAttributeQuotes: true,
        removeRedundantAttributes: true,
        useShortDoctype: true,
        removeEmptyAttributes: true,
        removeOptionalTags: true*/
        },
        files: [{
          expand: true,
          cwd: '<%= paths.source %>',
          src: '*.html',
          dest: '<%= paths.destination %>'
        }]
      }
    },
    copy: {
      js: {
        files: [{
          expand: true,
          flatten: false,
          cwd: '<%= paths.source %>/scripts/',
          src: ['main.js', '**/*.js'],
          dest: '<%= paths.destination %>/scripts/'
        }]
      },
      components: {
        files: [{
          expand: true,
          flatten: false,
          cwd: '<%= paths.source %>/components/',
          src: ['**/*.js', '**/*.css'],
          dest: '<%= paths.destination %>/components/'
        }]
      },
      images: {
        files: [{
          expand: true,
          cwd: '<%= paths.source %>/images/',
          src: ['**', '!pastel/**'],
          dest: '<%= paths.destination %>/images/'
        }]
      },
      fonts: {
        files: [{
          expand: true,
          cwd: '<%= paths.source %>/font/',
          src: '**',
          dest: '<%= paths.destination %>/font/'
        }, {
          expand: true,
          cwd: '<%= paths.source %>/components/font-awesome/font/',
          src: '**',
          dest: '<%= paths.destination %>/font/'
        }]
      },
      project: {
        files: [{
          cwd: '<%= paths.source %>',
          src: ['*.{ico,txt}', '.htaccess'],
          dest: '<%= paths.destination %>',
          expand: true,
          dot: true
        }]
      },
      dist: {
        files: [{
          src: '<%= paths.destination %>/**',
          dest: '../',  // This copy path should match the clean path (one dir up)
          expand: true,
          dot: true
        }]
      }
    },
    bower: {
      rjsConfig: '<%= paths.source %>/scripts/main.js',
      indent: '  '
    }
  });

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

    grunt.task.run([
      'clean:temp',
      'emberTemplates:server',
      'less:server',
      'livereload-start',
      'connect:livereload',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('cleanup', [
    'clean:temp'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    //'jshint',
    //'test',
    'emberTemplates:dist',
    'less:dist',
    'useminPrepare',
    //'imagemin',
    'htmlmin',
    'concat',
    'uglify',
    'usemin',
    'cssmin',
    'clean:public',
    'copy:images',
    'copy:fonts',
    'copy:project',
    'copy:dist',
    'clean:dist'
  ]);

  grunt.registerTask('build-lite', [
    'clean:dist',
    //'jshint',
    //'test',
    'emberTemplates:dist',
    'less:dist',
    'useminPrepare',
    //'imagemin',
    'htmlmin',
    'concat',
    //'uglify',
    'usemin',
    //'cssmin',
    'clean:public',
    'copy:images',
    'copy:fonts',
    'copy:project',
    'copy:dist',
    'clean:dist'
  ]);

  grunt.registerTask('build-debug', [
    'clean:dist',
    'jshint',
    //'test',
    'emberTemplates:dist',
    'less:debug',
    //'useminPrepare',
    //'imagemin',
    'htmlmin',
    'concat',
    //'uglify',
    //'usemin',
    //'cssmin',
    'clean:public',
    'copy',
    'clean:dist'
  ]);

  /*
   * Run "grunt scrape --server=127.0.0.1" from the command line
   */
  grunt.registerTask('scrape', 'Download JSON files from API', function () {
    var path = require('path');
    var fs = require('fs');
    var http = require('http');
    var request = require('request');
    var mkpath = require('mkpath');
    var done = this.async();

    var server = grunt.option('server') || 'localhost';
    var jsonFiles = [
      //'/api/v1/sessions/current_session.json',
      //'/api/v1/sessions.json',

      '/api/v1/status.json',
      '/api/v1/connectivity.json',
      '/api/v1/build.json',

      '/api/v1/quantumconfig',
      '/api/v1/openrcconfig',
      '/api/v1/novaconfig',
      '/api/v1/netconfig',
      '/api/v1/users.json',
      '/api/v1/logsettings',
      '/api/v1/override',
      '/api/v1/mailservers/default.json',

      '/api/v1/nodes.json',
      '/api/v1/vms.json',
      '/api/v1/configuration/flavors.json',
      '/api/v1/configuration/slas.json',
      '/api/v1/configuration/slos.json',
      //'/api/v1/graphs.json',

      '/api/v1/mtwilson/install',
      '/api/v1/trust_nodes.json',
      '/api/v1/trust_mles.json'
      //'/api/v1/node_trust_reports.json'

    ];

    jsonFiles.forEach(function (jsonFile) {
      var requestUrl = 'http://' + server + jsonFile;
      var absolutePath = __dirname + jsonFile.split('/').join(path.sep);
      request(requestUrl, function (error, response, body) {
        grunt.log.writeln(((response) ? response.statusCode : 'ERR') + ' GET ' + requestUrl);
        if (error) {
          grunt.log.writeln(error);
        } else if (response.statusCode === 200) {
          grunt.log.writeln(' Saving to ' + absolutePath);
          mkpath.sync(absolutePath.split(path.sep).slice(0, -1).join(path.sep));  // create folder
          var jsonObject = JSON.parse(body);
          var beautifiedJson = JSON.stringify(jsonObject, null, 2);
          fs.writeFile(absolutePath, beautifiedJson);
          // Download get_one child records
          var ids = [];
          var records = jsonObject[Object.keys(jsonObject)[0]];
          if (Array.isArray(records)) records.forEach(function (record) {
            if (record.id) ids.push(record.id);
          });
          ids.forEach(function (id) {
            var individualUrl = requestUrl.replace('.json', '') + '/' + id + '.json';
            var individualPath = __dirname + (jsonFile.replace('.json', '') + '/' + id + '.json').split('/').join(path.sep);
            request(individualUrl, function (error, response, body) {
              grunt.log.writeln(response.statusCode + ' GET ' + individualUrl);
              if (!error && response.statusCode === 200) {
                grunt.log.writeln(' Saving to ' + individualPath);
                mkpath.sync(individualPath.split(path.sep).slice(0, -1).join(path.sep));  // create folder
                fs.writeFile(individualPath, JSON.stringify(JSON.parse(body), null, 2));
              }
            });
          });
        }
      });
    });
  });

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