<commit_before>'use strict';
var path = require('path'),
    iniParser = require('node-ini'),
    fs = require('fs'),
    _ = require('lodash');

// Here we switch to the deployment environment.
// prod = production
// ci = continuous integration

//if (grunt.option('kb_deployment_config')) {
//           deployCfgFile = grunt.option('kb_deployment_config');
//       } else if (process.env.KB_DEPLOYMENT_CONFIG) {
//           deployCfgFile = process.env.KB_DEPLOYMENT_CONFIG;
//       }

function cancelTask() {
    var message = Array.prototype.slice.call(arguments).map(function (message) {
        return String(message);
    }).join(' ');
    console.error(message);
    process.exit(1);
}

module.exports = function (grunt) {

    var servicesTarget = 'prod',
        // set to 'test' for switching to dev menus, 'prod' for normal ones.
        uiTarget = 'prod';

    // Config
    // TODO: maybe read something from the runtime/config directory so we don't
    // need to tweak this and accidentally check it in...
    var BUILD_DIR = 'build';

    function buildDir(subdir) {
        if (subdir) {
            return path.normalize(BUILD_DIR + '/' + subdir);
        }
        return path.normalize(BUILD_DIR);
    }

    var REPO_DIR = '..';

    function makeRepoDir(subdir) {
        if (subdir) {
            return path.normalize(REPO_DIR + '/' + subdir);
        }
        return path.normalize(REPO_DIR);
    }

    function getConfig() {
        var deployCfgFile = 'deploy-' + servicesTarget + '.cfg';
        return iniParser.parseSync(deployCfgFile);
    }

    var deployCfg = getConfig();

    // not using this yet.
    function getBuildOptions() {
        servicesTarget = grunt.option('servicesTarget'); // prod or ci
        uiTarget = grunt.option('uiTarget'); // prod or test

        if (!servicesTarget || ['prod', 'ci'].indexOf(servicesTarget) === -1) {
            cancelTask(' Invalid value for required option "servicesTarget":', servicesTarget);
        }

        if (!uiTarget || ['prod', 'test'].indexOf(uiTarget) === -1) {
            cancelTask('Invalid value for required option "uiTarget":', uiTarget);
        }
    }

    function buildConfigFile() {
        'use strict';

        var serviceTemplateFile = 'config/service-config-template.yml',
            settingsCfg = 'config/settings.yml',
            outFile = buildDir('client/config.yml'),
            done = this.async();
        fs.readFile(serviceTemplateFile, 'utf8', function (err, serviceTemplate) {
            if (err) {
                console.log(err);
                throw 'Error reading service template';
            }

            var compiled = _.template(serviceTemplate),
                services = compiled(deployCfg['ui-common']);

            fs.readFile(settingsCfg, 'utf8', function (err, settings) {
                if (err) {
                    console.log(err);
                    throw 'Error reading UI settings file';
                }

                fs.writeFile(outFile, services + '\n\n' + settings, function (err) {
                    if (err) {
                        console.log(err);
                        throw 'Error writing compiled configuration';
                    }
                    done();
                });
            });
        });
    }

    // Project configuration
    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-mkdir');
    grunt.loadNpmTasks('grunt-shell');
    //grunt.loadNpmTasks('grunt-contrib-requirejs');
    //grunt.loadNpmTasks('grunt-karma');
    //grunt.loadNpmTasks('grunt-coveralls');
    grunt.loadNpmTasks('grunt-connect');
    grunt.loadNpmTasks('grunt-open');
    //grunt.loadNpmTasks('grunt-http-server');
    //grunt.loadNpmTasks('grunt-markdown');

    /*
     * This section sets up a mapping for bower packages.
     * Believe it or not this is shorter and easier to maintain
     * than plain grunt-contrib-copy
     *
     */
    var bowerFiles = [
        {
            name: 'bluebird',
            cwd: 'js/browser',
            src: ['bluebird.js'],
        },
        {
            name: 'bootstrap',
            cwd: 'dist',
            src: '**/*',
        },
        {
            name: 'd3'
        },
        {
            name: 'font-awesome',
            src: ['css/font-awesome.css', 'fonts/*']
        },
        {
            name: 'jquery',
            cwd: 'dist',
            src: ['jquery.js'],
        },
        {
            name: 'js-yaml',
            cwd: 'dist'
        },
        {
            name: 'kbase-common-js',
            cwd: 'src/js',
            src: ['**/*']
        },
        {
            name: 'lodash'
        },
        {
            dir: 'node-uuid',
            src: ['uuid.js']
        },
        {
            dir: 'postal.js',
            cwd: 'lib',
            name: 'postal'
        },
        {
            name: 'require-css',
            src: 'css.js'
        },
        {
            dir: 'require-yaml',
            name: 'yaml'
        },
        {
            dir: 'requirejs',
            name: 'require'
        },
        {
            dir: 'requirejs-domready',
            name: 'domReady'
        },
        {
            dir: 'requirejs-json',
            name: 'json'
        },
        {
            dir: 'requirejs-text',
            name: 'text'
        },
        {
            dir: 'SparkMD5',
            name: 'spark-md5'
        },
        {
            name: 'underscore'
        },
        {
            name: 'datatables',
            cwd: 'media',
            src: ['css/jquery.dataTables.css', 'images/*', 'js/jquery.dataTables.js']
        },
        {
            name: 'datatables-bootstrap3',
            dir: 'datatables-bootstrap3-plugin',
            cwd: 'media',
            src: ['css/datatables-bootstrap3.css', 'js/datatables-bootstrap3.js']
        },
        {
            name: 'vega'
        },
        {
            name: 'google-code-prettify',
            dir: 'google-code-prettify',
            cwd: 'src',
            src: ['prettify.js', 'prettify.css']
        },
        {
            dir: 'd3-plugins-sankey',
            src: ['sankey.js', 'sankey.css']
        },
        {
            name: 'handlebars'
        },
        {
            name: 'nunjucks',
            cwd: 'browser',
            src: 'nunjucks.js'
        },
        {
            dir: 'numeral',
            src: ['numeral.js', 'languages/*.js']
        },
        // PLUGINS
        {
            name: 'kbase-ui-plugin-databrowser',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-typebrowser',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-dataview',
            cwd: 'src/plugin',
            src: ['**/*']
        },

        {
            name: 'kbase-ui-plugin-typeview',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-dashboard',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-vis-widgets',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            dir: 'data-api',
            cwd: 'bower',
            src: '**/*'
        },
//        {
//            dir: 'kbase-data-api-js-wrappers',
//            cwd: 'bower',
//            src: '**/*'
//        },
        {
            dir: 'thrift-binary-protocol',
            cwd: 'src',
            src: '**/*'
        },
        {
            name: 'kbase-service-clients-js',
            cwd: 'dist/plugin',
            src: ['**/*']
        }

    ],
        bowerCopy = bowerFiles.map(function (cfg) {
            // path is like dir/path/name
            var path = [];
            // dir either dir or name is the first level directory.
            // path.unshift(cfg.dir || cfg.name);

            // If there is a path (subdir) we add that too.
            if (cfg.path) {
                path.unshift(cfg.path);
            }

            // Until we get a path which we use as a prefix to the src.
            var pathString = path
                .filter(function (el) {
                    if (el === null || el === undefined || el === '') {
                        return false;
                    }
                    return true;
                })
                .join('/');

            var srcs = (function () {
                if (cfg.src === undefined) {
                    return [cfg.name + '.js'];
                } else {
                    if (typeof cfg.src === 'string') {
                        return [cfg.src];
                    } else {
                        return cfg.src;
                    }
                }
            }());

            var sources = srcs.map(function (s) {
                return [pathString, s]
                    .filter(function (el) {
                        if (el === null || el === undefined || el === '') {
                            return false;
                        }
                        return true;
                    })
                    .join('/');
            });

            var cwd = cfg.cwd;
            if (cwd && cwd.charAt(0) === '/') {
            } else {
                cwd = 'bower_components/' + (cfg.dir || cfg.name) + (cwd ? '/' + cwd : '')
            }
            return {
                nonull: true,
                expand: true,
                cwd: cwd,
                src: sources,
                dest: buildDir('client/bower_components') + '/' + (cfg.dir || cfg.name)
            };
        });

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        copy: {
            bower: {
                files: bowerCopy
            },
            build: {
                files: [
                    {
                        cwd: 'src/client',
                        src: '**/*',
                        dest: buildDir('client'),
                        expand: true
                    },
                    {
                        cwd: 'src/data',
                        src: '**/*',
                        dest: buildDir('client/data'),
                        expand: true
                    },
                    //{
                    //    src: 'src/config/ci.yml',
                    //    dest: buildDir('client/config/client.yml')
                    //},
                    {
                        src: 'lib/kbase-client-api.js',
                        dest: buildDir('client'),
                        expand: true
                    }
                ]
            },
            dev: {
                files: [
// Uncomment to have these built into kbase-ui directly from a local repo.
// plugins as defined in ui-test.yml also need to be adjusted.
//                    {
//                        cwd: makeRepoDir('kbase-ui-plugin-dataview/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/dataview'),
//                        expand: true
//                    },
//                    {
//                        cwd: makeRepoDir('kbase-ui-plugin-typebrowser/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/typebrowser'),
//                        expand: true
//                    }

//                    {
//                        cwd: makeRepoDir('dashboard/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/dashboard'),
//                        expand: true
//                    },
//                    {
//                        cwd: makeRepoDir('kbase-ui-plugin-databrowser/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/databrowser'),
//                        expand: true
//                    },
                ]
            },
            deploy: {
                files: [
                    {
                        cwd: 'build/client',
                        src: '**/*',
                        dest: deployCfg['ui-common']['deploy_target'],
                        expand: true
                    }
                ]
            },
            config: {
                files: [
                    {
                        src: 'config/ui-' + uiTarget + '.yml',
                        dest: buildDir('client/ui.yml')
                    }
                ]
            },
        },
        clean: {
            build: {
                src: [buildDir()]
            }
        },
        connect: {
            server: {
                port: 8887,
                base: 'build/client',
                keepalive: false,
                onCreateServer: function (server, connect, options) {
                    console.log('created...');
                }
            }
        },
        'http-server': {
            dev: {
                root: buildDir('client'),
                port: 8887,
                host: '0.0.0.0',
                autoIndex: true,
                runInBackground: true
            }
        },
        open: {
            dev: {
                path: 'http://localhost:8887'
            }
        },
        // Testing with Karma!
        'karma': {
            unit: {
                configFile: 'test/karma.conf.js'
            },
            dev: {
                // to do - add watch here
                configFile: 'test/karma.conf.js',
                reporters: ['progress', 'coverage'],
                coverageReporter: {
                    dir: 'build/test-coverage/',
                    reporters: [
                        {type: 'html', subdir: 'html'}
                    ]
                },
                autoWatch: true,
                singleRun: false
            }
        },
        // Run coveralls and send the info.
        'coveralls': {
            options: {
                force: true
            },
            'ui-common': {
                src: 'build/test-coverage/lcov/**/*.info'
            }
        },
        bower: {
            install: {
                options: {
                    copy: false
                }
            }
        },
        markdown: {
            build: {
                files: [
                    {
                        expand: true,
                        src: 'src/docs/**/*.md',
                        dest: buildDir('docs'),
                        ext: '.html'
                    }
                ],
                options: {
                }
            }
        }
    });

    grunt.registerTask('get-build-options', 'Set build options from command line or environment', getBuildOptions);
    grunt.registerTask('build-config', 'Build the config file', buildConfigFile);

    // Does the whole building task
    grunt.registerTask('build', [
        // 'get-build-options',
        'bower:install',
        'copy:bower',
        'copy:build',
        'copy:dev',
        'copy:config',
        'build-config'
            // 'copy:config-prod'
    ]);

    /*
     grunt.registerTask('build-test', [
     'bower:install',
     'copy:build',
     'copy:bower',
     'copy:config-test'
     ]);

     grunt.registerTask('deploy', [
     'copy:deploy'
     ]);

     // Does a single, local, unit test run.
     grunt.registerTask('test', [
     'karma:unit',
     ]);

     // Does a single unit test run, then sends
     // the lcov results to coveralls. Intended for running
     // from travis-ci.
     grunt.registerTask('test-travis', [
     'karma:unit',
     'coveralls'
     ]);

     // Does an ongoing test run in a watching development
     // mode.
     grunt.registerTask('develop', [
     'karma:dev',
     ]);
     */
    grunt.registerTask('preview', [
        'open:dev',
        'connect'
    ]);

};
<commit_msg>Replace grunt task with shell call to grunt update. Fixes 'build' not picking up changes to dependencies from their upstream sources<commit_after>'use strict';
var path = require('path'),
    iniParser = require('node-ini'),
    fs = require('fs'),
    _ = require('lodash');

// Here we switch to the deployment environment.
// prod = production
// ci = continuous integration

//if (grunt.option('kb_deployment_config')) {
//           deployCfgFile = grunt.option('kb_deployment_config');
//       } else if (process.env.KB_DEPLOYMENT_CONFIG) {
//           deployCfgFile = process.env.KB_DEPLOYMENT_CONFIG;
//       }

function cancelTask() {
    var message = Array.prototype.slice.call(arguments).map(function (message) {
        return String(message);
    }).join(' ');
    console.error(message);
    process.exit(1);
}

module.exports = function (grunt) {

    var servicesTarget = 'prod',
        // set to 'test' for switching to dev menus, 'prod' for normal ones.
        uiTarget = 'test';

    // Config
    // TODO: maybe read something from the runtime/config directory so we don't
    // need to tweak this and accidentally check it in...
    var BUILD_DIR = 'build';

    function buildDir(subdir) {
        if (subdir) {
            return path.normalize(BUILD_DIR + '/' + subdir);
        }
        return path.normalize(BUILD_DIR);
    }

    var REPO_DIR = '..';

    function makeRepoDir(subdir) {
        if (subdir) {
            return path.normalize(REPO_DIR + '/' + subdir);
        }
        return path.normalize(REPO_DIR);
    }

    function getConfig() {
        var deployCfgFile = 'deploy-' + servicesTarget + '.cfg';
        return iniParser.parseSync(deployCfgFile);
    }

    var deployCfg = getConfig();

    // not using this yet.
    function getBuildOptions() {
        servicesTarget = grunt.option('servicesTarget'); // prod or ci
        uiTarget = grunt.option('uiTarget'); // prod or test

        if (!servicesTarget || ['prod', 'ci'].indexOf(servicesTarget) === -1) {
            cancelTask(' Invalid value for required option "servicesTarget":', servicesTarget);
        }

        if (!uiTarget || ['prod', 'test'].indexOf(uiTarget) === -1) {
            cancelTask('Invalid value for required option "uiTarget":', uiTarget);
        }
    }

    function buildConfigFile() {
        'use strict';

        var serviceTemplateFile = 'config/service-config-template.yml',
            settingsCfg = 'config/settings.yml',
            outFile = buildDir('client/config.yml'),
            done = this.async();
        fs.readFile(serviceTemplateFile, 'utf8', function (err, serviceTemplate) {
            if (err) {
                console.log(err);
                throw 'Error reading service template';
            }

            var compiled = _.template(serviceTemplate),
                services = compiled(deployCfg['ui-common']);

            fs.readFile(settingsCfg, 'utf8', function (err, settings) {
                if (err) {
                    console.log(err);
                    throw 'Error reading UI settings file';
                }

                fs.writeFile(outFile, services + '\n\n' + settings, function (err) {
                    if (err) {
                        console.log(err);
                        throw 'Error writing compiled configuration';
                    }
                    done();
                });
            });
        });
    }

    // Project configuration
    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-mkdir');
    grunt.loadNpmTasks('grunt-shell');
    //grunt.loadNpmTasks('grunt-contrib-requirejs');
    //grunt.loadNpmTasks('grunt-karma');
    //grunt.loadNpmTasks('grunt-coveralls');
    grunt.loadNpmTasks('grunt-connect');
    grunt.loadNpmTasks('grunt-open');
    //grunt.loadNpmTasks('grunt-http-server');
    //grunt.loadNpmTasks('grunt-markdown');

    /*
     * This section sets up a mapping for bower packages.
     * Believe it or not this is shorter and easier to maintain
     * than plain grunt-contrib-copy
     *
     */
    var bowerFiles = [
        {
            name: 'bluebird',
            cwd: 'js/browser',
            src: ['bluebird.js'],
        },
        {
            name: 'bootstrap',
            cwd: 'dist',
            src: '**/*',
        },
        {
            name: 'd3'
        },
        {
            name: 'font-awesome',
            src: ['css/font-awesome.css', 'fonts/*']
        },
        {
            name: 'jquery',
            cwd: 'dist',
            src: ['jquery.js'],
        },
        {
            name: 'js-yaml',
            cwd: 'dist'
        },
        {
            name: 'kbase-common-js',
            cwd: 'src/js',
            src: ['**/*']
        },
        {
            name: 'lodash'
        },
        {
            dir: 'node-uuid',
            src: ['uuid.js']
        },
        {
            dir: 'postal.js',
            cwd: 'lib',
            name: 'postal'
        },
        {
            name: 'require-css',
            src: 'css.js'
        },
        {
            dir: 'require-yaml',
            name: 'yaml'
        },
        {
            dir: 'requirejs',
            name: 'require'
        },
        {
            dir: 'requirejs-domready',
            name: 'domReady'
        },
        {
            dir: 'requirejs-json',
            name: 'json'
        },
        {
            dir: 'requirejs-text',
            name: 'text'
        },
        {
            dir: 'SparkMD5',
            name: 'spark-md5'
        },
        {
            name: 'underscore'
        },
        {
            name: 'datatables',
            cwd: 'media',
            src: ['css/jquery.dataTables.css', 'images/*', 'js/jquery.dataTables.js']
        },
        {
            name: 'datatables-bootstrap3',
            dir: 'datatables-bootstrap3-plugin',
            cwd: 'media',
            src: ['css/datatables-bootstrap3.css', 'js/datatables-bootstrap3.js']
        },
        {
            name: 'vega'
        },
        {
            name: 'google-code-prettify',
            dir: 'google-code-prettify',
            cwd: 'src',
            src: ['prettify.js', 'prettify.css']
        },
        {
            dir: 'd3-plugins-sankey',
            src: ['sankey.js', 'sankey.css']
        },
        {
            name: 'handlebars'
        },
        {
            name: 'nunjucks',
            cwd: 'browser',
            src: 'nunjucks.js'
        },
        {
            dir: 'numeral',
            src: ['numeral.js', 'languages/*.js']
        },
        // PLUGINS
        {
            name: 'kbase-ui-plugin-databrowser',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-typebrowser',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-dataview',
            cwd: 'src/plugin',
            src: ['**/*']
        },

        {
            name: 'kbase-ui-plugin-typeview',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-dashboard',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            name: 'kbase-ui-plugin-vis-widgets',
            cwd: 'src/plugin',
            src: ['**/*']
        },
        {
            dir: 'data-api',
            cwd: 'bower',
            src: '**/*'
        },
//        {
//            dir: 'kbase-data-api-js-wrappers',
//            cwd: 'bower',
//            src: '**/*'
//        },
        {
            dir: 'thrift-binary-protocol',
            cwd: 'src',
            src: '**/*'
        },
        {
            name: 'kbase-service-clients-js',
            cwd: 'dist/plugin',
            src: ['**/*']
        }

    ],
        bowerCopy = bowerFiles.map(function (cfg) {
            // path is like dir/path/name
            var path = [];
            // dir either dir or name is the first level directory.
            // path.unshift(cfg.dir || cfg.name);

            // If there is a path (subdir) we add that too.
            if (cfg.path) {
                path.unshift(cfg.path);
            }

            // Until we get a path which we use as a prefix to the src.
            var pathString = path
                .filter(function (el) {
                    if (el === null || el === undefined || el === '') {
                        return false;
                    }
                    return true;
                })
                .join('/');

            var srcs = (function () {
                if (cfg.src === undefined) {
                    return [cfg.name + '.js'];
                } else {
                    if (typeof cfg.src === 'string') {
                        return [cfg.src];
                    } else {
                        return cfg.src;
                    }
                }
            }());

            var sources = srcs.map(function (s) {
                return [pathString, s]
                    .filter(function (el) {
                        if (el === null || el === undefined || el === '') {
                            return false;
                        }
                        return true;
                    })
                    .join('/');
            });

            var cwd = cfg.cwd;
            if (cwd && cwd.charAt(0) === '/') {
            } else {
                cwd = 'bower_components/' + (cfg.dir || cfg.name) + (cwd ? '/' + cwd : '')
            }
            return {
                nonull: true,
                expand: true,
                cwd: cwd,
                src: sources,
                dest: buildDir('client/bower_components') + '/' + (cfg.dir || cfg.name)
            };
        });

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        copy: {
            bower: {
                files: bowerCopy
            },
            build: {
                files: [
                    {
                        cwd: 'src/client',
                        src: '**/*',
                        dest: buildDir('client'),
                        expand: true
                    },
                    {
                        cwd: 'src/data',
                        src: '**/*',
                        dest: buildDir('client/data'),
                        expand: true
                    },
                    //{
                    //    src: 'src/config/ci.yml',
                    //    dest: buildDir('client/config/client.yml')
                    //},
                    {
                        src: 'lib/kbase-client-api.js',
                        dest: buildDir('client'),
                        expand: true
                    }
                ]
            },
            dev: {
                files: [
// Uncomment to have these built into kbase-ui directly from a local repo.
// plugins as defined in ui-test.yml also need to be adjusted.

//                    {
//                        cwd: makeRepoDir('kbase-ui-plugin-dataview/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/dataview'),
//                        expand: true
//                    },
//                    {
//                        cwd: makeRepoDir('kbase-ui-plugin-typebrowser/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/typebrowser'),
//                        expand: true
//                    },
//                    {
//                        cwd: makeRepoDir('kbase-ui-plugin-databrowser/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/databrowser'),
//                        expand: true
//                    }

//                    {
//                        cwd: makeRepoDir('dashboard/src/plugin'),
//                        src: '**/*',
//                        dest: buildDir('client/plugins/dashboard'),
//                        expand: true
//                    },

                ]
            },
            deploy: {
                files: [
                    {
                        cwd: 'build/client',
                        src: '**/*',
                        dest: deployCfg['ui-common']['deploy_target'],
                        expand: true
                    }
                ]
            },
            config: {
                files: [
                    {
                        src: 'config/ui-' + uiTarget + '.yml',
                        dest: buildDir('client/ui.yml')
                    }
                ]
            },
        },
        clean: {
            build: {
                src: [buildDir()]
            }
        },
        connect: {
            server: {
                port: 8887,
                base: 'build/client',
                keepalive: false,
                onCreateServer: function (server, connect, options) {
                    console.log('created...');
                }
            }
        },
        'http-server': {
            dev: {
                root: buildDir('client'),
                port: 8887,
                host: '0.0.0.0',
                autoIndex: true,
                runInBackground: true
            }
        },
        open: {
            dev: {
                path: 'http://localhost:8887'
            }
        },
        // Testing with Karma!
        'karma': {
            unit: {
                configFile: 'test/karma.conf.js'
            },
            dev: {
                // to do - add watch here
                configFile: 'test/karma.conf.js',
                reporters: ['progress', 'coverage'],
                coverageReporter: {
                    dir: 'build/test-coverage/',
                    reporters: [
                        {type: 'html', subdir: 'html'}
                    ]
                },
                autoWatch: true,
                singleRun: false
            }
        },
        // Run coveralls and send the info.
        'coveralls': {
            options: {
                force: true
            },
            'ui-common': {
                src: 'build/test-coverage/lcov/**/*.info'
            }
        },
        bower: {
            install: {
                options: {
                    copy: false
                }
            }
        },
        shell: {
            bowerUpdate: {
                command: [
                    'bower',
                    'update'
                ].join(' '),
                options: {
                    stderr: false
                }
            }
        },
        markdown: {
            build: {
                files: [
                    {
                        expand: true,
                        src: 'src/docs/**/*.md',
                        dest: buildDir('docs'),
                        ext: '.html'
                    }
                ],
                options: {
                }
            }
        }
    });

    grunt.registerTask('get-build-options', 'Set build options from command line or environment', getBuildOptions);
    grunt.registerTask('build-config', 'Build the config file', buildConfigFile);

    // Does the whole building task
    grunt.registerTask('build', [
        // 'get-build-options',
        // 'bower:install',
        'shell:bowerUpdate',
        'copy:bower',
        'copy:build',
        'copy:dev',
        'copy:config',
        'build-config'
            // 'copy:config-prod'
    ]);

    /*
     grunt.registerTask('build-test', [
     'bower:install',
     'copy:build',
     'copy:bower',
     'copy:config-test'
     ]);

     grunt.registerTask('deploy', [
     'copy:deploy'
     ]);

     // Does a single, local, unit test run.
     grunt.registerTask('test', [
     'karma:unit',
     ]);

     // Does a single unit test run, then sends
     // the lcov results to coveralls. Intended for running
     // from travis-ci.
     grunt.registerTask('test-travis', [
     'karma:unit',
     'coveralls'
     ]);

     // Does an ongoing test run in a watching development
     // mode.
     grunt.registerTask('develop', [
     'karma:dev',
     ]);
     */
    grunt.registerTask('preview', [
        'open:dev',
        'connect'
    ]);

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

  // 1 - Configuração dos plugins
  grunt.initConfig({
    jshint: {
      options: {
        maxparams: 5,
        eqeqeq: true,
        undef: true
      },
      files: [ 'src/**/*.js' ]
    },
    clean: [ '.tmp', 'dist' ],
    copy: {
      html: {
        files: [
          { src: 'index.html', dest: 'dist/' }
        ]
      }
    },
    useminPrepare: {
      html: [ 'index.html' ],
      options: {
        dest: 'dist'
      }
    },
    usemin: {
      html: 'dist/index.html'
    },
    filerev: {
      images: {
        src: [ 'dist/img/**/*.{png,jpg,gif}' ],
      },
      styles: {
        src: [ 'dist/**/*.css' ]
      },
      scripts: {
        src: [ 'dist/**/*.js' ]
      }
    },
    imagemin: {
      dynamic: {
        files: [{
          expand: true,
          cwd: 'img',
          src: '**/*.{png,jpg,gif}',
          dest: 'dist/img/'
        }]
      }
    },
    compress: {
      build: {
        options: {
          archive: function() {
            return new Date().getTime() + '-build-package.zip';
          },
          mode: 'zip'
        },
        files: [
          { src: 'dist/**', flatten: true }
        ]
      }
    }
  });

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

  grunt.registerTask('default', [
    'clean',
    'copy:html',
    'useminPrepare',
    'concat:generated',
    'cssmin:generated',
    'uglify:generated',
    'imagemin',
    'filerev',
    'usemin',
    'compress'
  ]);
};<commit_msg>style(Gruntfile): translate portuguese comments to english (#1).<commit_after>'use strict';

module.exports = function(grunt) {

  // 1 - Configuring external plugin specific targets
  grunt.initConfig({
    jshint: {
      options: {
        maxparams: 5,
        eqeqeq: true,
        undef: true
      },
      files: [ 'src/**/*.js' ]
    },
    clean: [ '.tmp', 'dist' ],
    copy: {
      html: {
        files: [
          { src: 'index.html', dest: 'dist/' }
        ]
      }
    },
    useminPrepare: {
      html: [ 'index.html' ],
      options: {
        dest: 'dist'
      }
    },
    usemin: {
      html: 'dist/index.html'
    },
    filerev: {
      images: {
        src: [ 'dist/img/**/*.{png,jpg,gif}' ],
      },
      styles: {
        src: [ 'dist/**/*.css' ]
      },
      scripts: {
        src: [ 'dist/**/*.js' ]
      }
    },
    imagemin: {
      dynamic: {
        files: [{
          expand: true,
          cwd: 'img',
          src: '**/*.{png,jpg,gif}',
          dest: 'dist/img/'
        }]
      }
    },
    compress: {
      build: {
        options: {
          archive: function() {
            return new Date().getTime() + '-build-package.zip';
          },
          mode: 'zip'
        },
        files: [
          { src: 'dist/**', flatten: true }
        ]
      }
    }
  });

  // 2 - Loading external plugins from package.json
  require('load-grunt-tasks')(grunt);

  // 3 - Customizing default task pipeline
  grunt.registerTask('default', [
    'clean',
    'copy:html',
    'useminPrepare',
    'concat:generated',
    'cssmin:generated',
    'uglify:generated',
    'imagemin',
    'filerev',
    'usemin',
    'compress'
  ]);
};<|endoftext|>


<commit_before>// Generated on 2014-04-03 using generator-angular-fullstack 1.3.3
'use strict';

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

process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var config = require('./lib/config/config');

module.exports = function (grunt) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    var done = this.async();

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

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

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

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

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

  grunt.registerTask('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', function(target) {
    if (target === 'server') {
      return grunt.task.run([
        'env:test',
        'mochaTest'
      ]);
    }

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

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

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

  grunt.registerTask('heroku', function () {
    grunt.log.warn('The `heroku` task has been deprecated. Use `grunt build` to build for deployment.');
    grunt.task.run(['build']);
  });

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Clean up Gruntfile.js<commit_after>// Generated on 2014-04-03 using generator-angular-fullstack 1.3.3
'use strict';

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

process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var config = require('./lib/config/config');

module.exports = function (grunt) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    var done = this.async();

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

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

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

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

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

  grunt.registerTask('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', function(target) {
    if (target === 'server') {
      return grunt.task.run([
        'env:test',
        'mochaTest'
      ]);

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

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

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

  grunt.registerTask('heroku', function () {
    grunt.log.warn('The `heroku` task has been deprecated. Use `grunt build` to build for deployment.');
    grunt.task.run(['build']);
  });

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


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

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    webdriver: {
      options: {
          host: (process.env.BUILD_NUMBER) ? 'localhost':'ondemand.saucelabs.com',
          port: (process.env.BUILD_NUMBER) ? 4445:80,
          user: process.env.SAUCE_USERNAME,
          key: process.env.SAUCE_ACCESS_KEY,
          tags: ['saucelabs'],
          name: 'This is an example test script using grunt-driver and saucelabs'
      },
      ieexample: {
        tests: ['gruntSaucelabs.js', 'tutorial1.js', 'copyright1.js', 'cssValidation1.js', 'dataLoopExample2.js', 'formFieldValidation.js', 'formFillSubmit1.js', 'linkTextURL1.js', 'linkTextURL2.js'],
        options: {
          desiredCapabilities: {
            browserName: 'internet explorer',
            version: '10.0',
            platform: 'Windows 7'
          }
        }
      },
      chromeexample: {
        tests: ['gruntSaucelabs.js', 'tutorial1.js', 'copyright1.js', 'cssValidation1.js', 'dataLoopExample2.js', 'formFieldValidation.js', 'formFillSubmit1.js', 'linkTextURL1.js', 'linkTextURL2.js'],
        options: {
          desiredCapabilities: {
            browserName: 'chrome',
            version: '42.0',
            platform: 'Windows 8'
          }
        }
      },
      safariexample: {
        tests: ['gruntSaucelabs.js', 'tutorial1.js', 'copyright1.js', 'cssValidation1.js', 'dataLoopExample2.js', 'formFieldValidation.js', 'formFillSubmit1.js', 'linkTextURL1.js', 'linkTextURL2.js'],
        options: {
          desiredCapabilities: {
            browserName: 'safari',
            version: '8.0',
            platform: 'OS X 10.10'
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-webdriver');
};<commit_msg>Added run instructions<commit_after>// Default Gruntfile
//
// To Run:
//  $ grunt webdriver

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    webdriver: {
      options: {
          host: (process.env.BUILD_NUMBER) ? 'localhost':'ondemand.saucelabs.com',
          port: (process.env.BUILD_NUMBER) ? 4445:80,
          user: process.env.SAUCE_USERNAME,
          key: process.env.SAUCE_ACCESS_KEY,
          tags: ['saucelabs'],
          name: 'This is an example test script using grunt-driver and saucelabs'
      },
      ieexample: {
        tests: ['gruntSaucelabs.js', 'tutorial1.js', 'copyright1.js', 'cssValidation1.js', 'dataLoopExample2.js', 'formFieldValidation.js', 'formFillSubmit1.js', 'linkTextURL1.js', 'linkTextURL2.js'],
        options: {
          desiredCapabilities: {
            browserName: 'internet explorer',
            version: '10.0',
            platform: 'Windows 7'
          }
        }
      },
      chromeexample: {
        tests: ['gruntSaucelabs.js', 'tutorial1.js', 'copyright1.js', 'cssValidation1.js', 'dataLoopExample2.js', 'formFieldValidation.js', 'formFillSubmit1.js', 'linkTextURL1.js', 'linkTextURL2.js'],
        options: {
          desiredCapabilities: {
            browserName: 'chrome',
            version: '42.0',
            platform: 'Windows 8'
          }
        }
      },
      safariexample: {
        tests: ['gruntSaucelabs.js', 'tutorial1.js', 'copyright1.js', 'cssValidation1.js', 'dataLoopExample2.js', 'formFieldValidation.js', 'formFillSubmit1.js', 'linkTextURL1.js', 'linkTextURL2.js'],
        options: {
          desiredCapabilities: {
            browserName: 'safari',
            version: '8.0',
            platform: 'OS X 10.10'
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-webdriver');
};<|endoftext|>


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

  'use strict';

  grunt.initConfig({

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

    php: {
      dev: {
        options: {
          bin: '/usr/bin/php', // Mavericks and Yosemite
          // bin: '/usr/local/php5/bin/php', // Mountain Lion (See http://php-osx.liip.ch for PHP 5.4.0+)
          keepalive: true,
          open: true
        }
      }
    },

    phpunit: {
      classes: {
          dir: 'tests/unit/'
      },
      options: {
          bin: 'vendor/bin/phpunit',
          bootstrap: 'tests/unit/bootstrap.php',
          colors: true
      }
    },

    sass: {
      dev: {
        options: {
          style: 'nested',
          sourceMap: true
        },
        files: [{
          cwd:    'stylesheets/',
          dest:   'css/',
          expand: true,
          ext:    '.css',
          extDot: 'first',
          src:    '*.scss'
        }]
      },
      dist: {
        options: {
          style: 'compressed'
        },
        files: [{
          cwd:    'stylesheets/',
          dest:   'css/',
          expand: true,
          flatten: true,
          ext:    '.css',
          extDot: 'first',
          src:    '*.scss'
        }]
      },
    },

    autoprefixer: {
      dev: {
        options: {
          browsers: ['last 2 version', 'ie 7', 'ie 8', 'ie 9']
        },
        expand: true,
        src:    'css/*.css',
        dest:   'css/'
      }
    },

    watch: {
      css: {
        files: ['stylesheets/**/*.scss'],
        tasks: ['sass:dev', 'autoprefixer'],
        options: {
          livereload: true,
        },
      },
    },

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

    uglify: {
      concat: {
        options: {
          banner: '<%= pkg.banner %>',
          beautify: true
        },
        files: {
          'dist/js/<%= pkg.name %>.js': ['js/**/*.js']
        }
      },
      minify: {
        options: {
          banner: '<%= pkg.banner %>',
          compress: true,
          report: 'min'
        },
        files: {
          'dist/js/<%= pkg.name %>.min.js': ['js/**/*.js']
        }
      }
    },

    asciify: {
      banner:{
        text: '<%= pkg.name %>',
        options: {
          font: 'univers',
          log: true
        }
      },
    },

    copy: {
      readme: {
        src: 'docs/index.md',
        dest: 'README.md',
      }
    },

    clean: {
      dist: ['dist'],
      smoketest: ['tmp/failures/*']
    },

    bump: {
      options: {
        updateConfigs: ['pkg'],
        files: ['pulsar.json', 'package.json', 'composer.json', 'bower.json', 'VERSION'],
        commit: true,
        commitMessage: 'Release v%VERSION%',
        commitFiles: ['-a'],
        createTag: true,
        tagName: '%VERSION%',
        push: true,
        pushTo: 'origin'
      }
    },

    exec: {
      phantomcss: {
        cmd: 'phantomjs tests/css/testsuite.js'
      },
      updateComposer: {
        cmd: 'sudo php composer.phar update'
      },
      updateBrew: {
        cmd: 'brew update && brew upgrade'
      },
      updateBower: {
        cmd: 'bower update'
      },
      updateGems: {
        cmd: 'sudo gem update'
      },
      updateNpm: {
        cmd: 'sudo npm install'
      }
    },

    concurrent: {
      dev: ['watch', 'php'],
      options: {
        logConcurrentOutput: true
      }
    }

  });

  grunt.config.set('leadingIndent.indentation', 'spaces');
  grunt.config.set('leadingIndent.files', {
    src : [
      'docs/**/*.md',
      'docs/**/*.php',
      'css/**/*',
      'js/**/*',
      'lexicon/**/*',
      'src/**/*',
      'stylesheets/**/*',
      'tests/**/*',
      'views/**/*'
    ]
  });

 grunt.registerTask('default', ['sass:dev', 'concurrent:dev']);

 grunt.registerTask('pre-commit', [
    'asciify',
    'phpunit',
    // 'leadingIndent:files',
    'copy:readme'
  ]);

  // grunt.registerTask('release', [
  //   'build',
  //   'bump'
  // ]);

  grunt.registerTask('smoketest', [
    'clean:smoketest',
    'exec:phantomcss'
  ]);

  grunt.registerTask('update', [
    'exec:updateComposer',
    'exec:updateBrew',
    'exec:updateBower',
    'exec:updateGems',
    'exec:updateNpm'
  ]);

  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

};
<commit_msg>Remove php grunt task now we got vagrant all up in here<commit_after>module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

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

    phpunit: {
      classes: {
          dir: 'tests/unit/'
      },
      options: {
          bin: 'vendor/bin/phpunit',
          bootstrap: 'tests/unit/bootstrap.php',
          colors: true
      }
    },

    sass: {
      dev: {
        options: {
          style: 'nested',
          sourceMap: true
        },
        files: [{
          cwd:    'stylesheets/',
          dest:   'css/',
          expand: true,
          ext:    '.css',
          extDot: 'first',
          src:    '*.scss'
        }]
      },
      dist: {
        options: {
          style: 'compressed'
        },
        files: [{
          cwd:    'stylesheets/',
          dest:   'css/',
          expand: true,
          flatten: true,
          ext:    '.css',
          extDot: 'first',
          src:    '*.scss'
        }]
      },
    },

    autoprefixer: {
      dev: {
        options: {
          browsers: ['last 2 version', 'ie 7', 'ie 8', 'ie 9']
        },
        expand: true,
        src:    'css/*.css',
        dest:   'css/'
      }
    },

    watch: {
      css: {
        files: ['stylesheets/**/*.scss'],
        tasks: ['sass:dev', 'autoprefixer'],
        options: {
          livereload: true,
        },
      },
    },

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

    uglify: {
      concat: {
        options: {
          banner: '<%= pkg.banner %>',
          beautify: true
        },
        files: {
          'dist/js/<%= pkg.name %>.js': ['js/**/*.js']
        }
      },
      minify: {
        options: {
          banner: '<%= pkg.banner %>',
          compress: true,
          report: 'min'
        },
        files: {
          'dist/js/<%= pkg.name %>.min.js': ['js/**/*.js']
        }
      }
    },

    asciify: {
      banner:{
        text: '<%= pkg.name %>',
        options: {
          font: 'univers',
          log: true
        }
      },
    },

    copy: {
      readme: {
        src: 'docs/index.md',
        dest: 'README.md',
      }
    },

    clean: {
      dist: ['dist'],
      smoketest: ['tmp/failures/*']
    },

    bump: {
      options: {
        updateConfigs: ['pkg'],
        files: ['pulsar.json', 'package.json', 'composer.json', 'bower.json', 'VERSION'],
        commit: true,
        commitMessage: 'Release v%VERSION%',
        commitFiles: ['-a'],
        createTag: true,
        tagName: '%VERSION%',
        push: true,
        pushTo: 'origin'
      }
    },

    exec: {
      phantomcss: {
        cmd: 'phantomjs tests/css/testsuite.js'
      },
      updateComposer: {
        cmd: 'sudo php composer.phar update'
      },
      updateBrew: {
        cmd: 'brew update && brew upgrade'
      },
      updateBower: {
        cmd: 'bower update'
      },
      updateGems: {
        cmd: 'sudo gem update'
      },
      updateNpm: {
        cmd: 'sudo npm install'
      }
    }

  });

  grunt.config.set('leadingIndent.indentation', 'spaces');
  grunt.config.set('leadingIndent.files', {
    src : [
      'docs/**/*.md',
      'docs/**/*.php',
      'css/**/*',
      'js/**/*',
      'lexicon/**/*',
      'src/**/*',
      'stylesheets/**/*',
      'tests/**/*',
      'views/**/*'
    ]
  });

 grunt.registerTask('default', ['sass:dev', 'watch']);

 grunt.registerTask('pre-commit', [
    'asciify',
    'phpunit',
    // 'leadingIndent:files',
    'copy:readme'
  ]);

  grunt.registerTask('smoketest', [
    'clean:smoketest',
    'exec:phantomcss'
  ]);

  grunt.registerTask('update', [
    'exec:updateComposer',
    'exec:updateBrew',
    'exec:updateBower',
    'exec:updateGems',
    'exec:updateNpm'
  ]);

  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {
  var glob = require('glob');
  var production_url = "https://ironcorelabs.com";
  var localhost = require("os").hostname();
  var dev_url = "http://"+localhost+":4000";

  //grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-typescript');
  grunt.loadNpmTasks('grunt-jekyll');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-notify');
  grunt.loadNpmTasks('grunt-check-pages');
  grunt.loadNpmTasks('grunt-htmllint');
  grunt.loadNpmTasks('grunt-html-validation');

  // Show elapsed time after tasks run
  require('time-grunt')(grunt);
  //require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    validation: {
      options: {
//        reset: grunt.option('reset') || false,
        stoponerror: true
      },
      files: {
        src: ['_site/**/*.html']
      }
    },
    htmllint: {
      dev: {
        options: {
          force: false,
          htmllintrc: true,
          plugins: []
        },
        src: [ '_site/**/*.html' ]
      },
      dist: {
        options: {
          force: false,
          htmllintrc: true,
          plugins: []
        },
        src: [
          '_site/**/*.html'
        ]
      }
    },
    checkPages: {
      dev: {
        options: {
          pageUrls: glob.sync('_site/**/*.html').map(function(file, idx, arr) {
            return dev_url + file.replace('_site', '');
          }).filter(function(v) {
            return !/\.md\//.test(v);
          }),
          checkLinks: true,
          queryHashes: false,
          noRedirects: false,
          noLocalLinks: true,
          noEmptyFragments: true,
          onlySameDomain: true,
          checkCaching: false,
          checkCompression: false,
          maxResponseTime: 500,
          summary: true,
          linksToIgnore: [
          ]
        }
      },
      production: {
        options: {
          pageUrls: glob.sync('_site/**/*.html').map(function(file, idx, arr) {
            return production_url + file.replace('_site', '');
          }).filter(function(v) {
            return !/\.md\//.test(v);
          }),
          checkLinks: true,
          queryHashes: false,
          noRedirects: true,
          noLocalLinks: true,
          noEmptyFragments: true,
          checkCaching: false,
          checkCompression: true,
          maxResponseTime: 800,
          summary: true
        }
      }
    },
    pkg: grunt.file.readJSON('package.json'),
    clean: [
      "_site",
      "**/*.bak",
      "js/**/*.map",
      "js/min/all.min.js",
      "js/all.ts.js",
      "css/**/*.map",
      "css/styles.css",
      ".sass-cache",
      ".DS_Store",
      ".codekit-cache",
      ".tscache",
      "validation-*.json"
    ],
    jekyll: {
      options: {
        bundleExec: true,
        safe: true
      },
      dev: {
        options: {
          drafts: true,
          future: true,
          config: '_config.yml,_config-dev.yml'
        }
      },
      dist: {
        options: {
          drafts: false,
          future: false,
          config: '_config.yml'
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      configFiles: {
        files: [ 'Gruntfile.js' ],
        options: {
          reload: true
        }
      },
      jekyll: {
        files: [
          '_posts/*',
          '_layouts/*',
          '_includes/*',
          '_drafts/*',
          'img/**/*.{jpg,png,svg}',
          '*.{html,yml,md}',
          '**/index.html',
          '*.xml',
          '!_site/**/*', // not anything in the output dir
          '!TODO.md' // don't rebuild when the TODO file changes
        ],
        tasks: ['jekyll:dev', 'validation', 'htmllint:dev']
      },
      compass: {
        files: [
          '_sass/*.scss'
        ],
        tasks: ['compass:dev', 'jekyll:dev']
      },
      typescript: {
        files: [
          'ts/*.ts',
          'js/plugins.js',
          "!node_modules/**/*.ts"
        ],
        tasks: ['typescript:dev', 'uglify:dev', 'jekyll:dev']
      }
    },
    typescript: {
      dev: {
        src: [
          "ts/*.ts",
          "!node_modules/**/*.ts"
        ],
        dest: 'js/all.ts.js',
        options: {
          target: 'es5',
          sourceMap: true,
          declaration: true,
          references: [
            'core', 'dom'
          ]
        }
      },
      dist: {
        src: [
          "ts/*.ts",
          "!node_modules/**/*.ts"
        ],
        dest: 'js/all.ts.js',
        options: {
          target: 'es5',
          sourceMap: false,
          declaration: true,
          references: [
            'core', 'dom'
          ]
        }
      }
    },
    compass: {
      options: {
        config: 'config.rb'
      },
      dist: {
        options: {
          environment: 'production',
          outputStyle: 'compressed',
          noLineComments: true,
          force: true
        }
      },
      dev: {
        options: {
          environment: 'development',
          outputStyle: 'expanded',
          noLineComments: false
        }
      }
    },
    connect: {
      server: {
        options: {
          port: 4000,
          base: '_site/',
          hostname: '0.0.0.0',
          keepalive: false
        }
      },
      keepalive: {
        options: {
          port: 4000,
          base: '_site/',
          hostname: '0.0.0.0',
          keepalive: true
        }
      }
    },
    uglify: {
      options: {
        mangle: false,
        compress: true
      },
      dev: {
        options: {
          sourceMapIncludeSources: true,
          sourceMap: true
        },
        files: {
          'js/min/all.min.js': [
            'js/plugins.js',
            'js/all.ts.js',
            'bower_components/Stickyfill/src/stickyfill.js',
//            'bower_components/jquery-waypoints/lib/jquery.waypoints.js',
//            'bower_components/immutable/dist/immutable.js',
//            'bower_components/underscore/underscore.js',
//            'js/bootstrap/carousel.js',
            'js/bootstrap/collapse.js',
            'js/bootstrap/transition.js',
            'js/bootstrap/tab.js',
            'js/bootstrap/dropdown.js',
            'js/bootstrap/button.js'
          ]
        }
      },
      dist: {
        options: {
          sourceMapIncludeSources: false,
          sourceMap: false
        },
        files: {
          'js/min/all.min.js': [
            'js/plugins.js',
            'js/all.ts.js',
            'bower_components/Stickyfill/src/stickyfill.js',
//            'bower_components/immutable/dist/immutable.js',
//            'bower_components/underscore/underscore.js',
//            'js/bootstrap/carousel.js',
            'js/bootstrap/collapse.js',
            'js/bootstrap/transition.js',
            'js/bootstrap/tab.js',
            'js/bootstrap/dropdown.js',
            'js/bootstrap/button.js'
          ]
        }
      }
    }
  });

  grunt.registerTask('dev', function(target) {
    grunt.task.run([
      'typescript:dev',
      'uglify:dev',
      'compass:dev',
      'jekyll:dev',
//      'validation',
//      'htmllint:dev',
      'connect:server',
      'checkPages:dev',
      'watch'
    ]);
  });
  grunt.registerTask('build', function(target) {
    grunt.task.run([
      'clean',
      'typescript:dist',
      'uglify:dist',
      'compass:dist',
      'jekyll:dist',
      'validation',
      'htmllint:dist'
//      'checkPages:dev'
    ]);
  });
  grunt.registerTask('dist', function(target) {
    // dist is an alias for build
    grunt.task.run(['build']);
  });

}
<commit_msg>Removing more dead waypoint code<commit_after>'use strict';

module.exports = function(grunt) {
  var glob = require('glob');
  var production_url = "https://ironcorelabs.com";
  var localhost = require("os").hostname();
  var dev_url = "http://"+localhost+":4000";

  //grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-typescript');
  grunt.loadNpmTasks('grunt-jekyll');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-notify');
  grunt.loadNpmTasks('grunt-check-pages');
  grunt.loadNpmTasks('grunt-htmllint');
  grunt.loadNpmTasks('grunt-html-validation');

  // Show elapsed time after tasks run
  require('time-grunt')(grunt);
  //require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    validation: {
      options: {
//        reset: grunt.option('reset') || false,
        stoponerror: true
      },
      files: {
        src: ['_site/**/*.html']
      }
    },
    htmllint: {
      dev: {
        options: {
          force: false,
          htmllintrc: true,
          plugins: []
        },
        src: [ '_site/**/*.html' ]
      },
      dist: {
        options: {
          force: false,
          htmllintrc: true,
          plugins: []
        },
        src: [
          '_site/**/*.html'
        ]
      }
    },
    checkPages: {
      dev: {
        options: {
          pageUrls: glob.sync('_site/**/*.html').map(function(file, idx, arr) {
            return dev_url + file.replace('_site', '');
          }).filter(function(v) {
            return !/\.md\//.test(v);
          }),
          checkLinks: true,
          queryHashes: false,
          noRedirects: false,
          noLocalLinks: true,
          noEmptyFragments: true,
          onlySameDomain: true,
          checkCaching: false,
          checkCompression: false,
          maxResponseTime: 500,
          summary: true,
          linksToIgnore: [
          ]
        }
      },
      production: {
        options: {
          pageUrls: glob.sync('_site/**/*.html').map(function(file, idx, arr) {
            return production_url + file.replace('_site', '');
          }).filter(function(v) {
            return !/\.md\//.test(v);
          }),
          checkLinks: true,
          queryHashes: false,
          noRedirects: true,
          noLocalLinks: true,
          noEmptyFragments: true,
          checkCaching: false,
          checkCompression: true,
          maxResponseTime: 800,
          summary: true
        }
      }
    },
    pkg: grunt.file.readJSON('package.json'),
    clean: [
      "_site",
      "**/*.bak",
      "js/**/*.map",
      "js/min/all.min.js",
      "js/all.ts.js",
      "css/**/*.map",
      "css/styles.css",
      ".sass-cache",
      ".DS_Store",
      ".codekit-cache",
      ".tscache",
      "validation-*.json"
    ],
    jekyll: {
      options: {
        bundleExec: true,
        safe: true
      },
      dev: {
        options: {
          drafts: true,
          future: true,
          config: '_config.yml,_config-dev.yml'
        }
      },
      dist: {
        options: {
          drafts: false,
          future: false,
          config: '_config.yml'
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      configFiles: {
        files: [ 'Gruntfile.js' ],
        options: {
          reload: true
        }
      },
      jekyll: {
        files: [
          '_posts/*',
          '_layouts/*',
          '_includes/*',
          '_drafts/*',
          'img/**/*.{jpg,png,svg}',
          '*.{html,yml,md}',
          '**/index.html',
          '*.xml',
          '!_site/**/*', // not anything in the output dir
          '!TODO.md' // don't rebuild when the TODO file changes
        ],
        tasks: ['jekyll:dev', 'validation', 'htmllint:dev']
      },
      compass: {
        files: [
          '_sass/*.scss'
        ],
        tasks: ['compass:dev', 'jekyll:dev']
      },
      typescript: {
        files: [
          'ts/*.ts',
          'js/plugins.js',
          "!node_modules/**/*.ts"
        ],
        tasks: ['typescript:dev', 'uglify:dev', 'jekyll:dev']
      }
    },
    typescript: {
      dev: {
        src: [
          "ts/*.ts",
          "!node_modules/**/*.ts"
        ],
        dest: 'js/all.ts.js',
        options: {
          target: 'es5',
          sourceMap: true,
          declaration: true,
          references: [
            'core', 'dom'
          ]
        }
      },
      dist: {
        src: [
          "ts/*.ts",
          "!node_modules/**/*.ts"
        ],
        dest: 'js/all.ts.js',
        options: {
          target: 'es5',
          sourceMap: false,
          declaration: true,
          references: [
            'core', 'dom'
          ]
        }
      }
    },
    compass: {
      options: {
        config: 'config.rb'
      },
      dist: {
        options: {
          environment: 'production',
          outputStyle: 'compressed',
          noLineComments: true,
          force: true
        }
      },
      dev: {
        options: {
          environment: 'development',
          outputStyle: 'expanded',
          noLineComments: false
        }
      }
    },
    connect: {
      server: {
        options: {
          port: 4000,
          base: '_site/',
          hostname: '0.0.0.0',
          keepalive: false
        }
      },
      keepalive: {
        options: {
          port: 4000,
          base: '_site/',
          hostname: '0.0.0.0',
          keepalive: true
        }
      }
    },
    uglify: {
      options: {
        mangle: false,
        compress: true
      },
      dev: {
        options: {
          sourceMapIncludeSources: true,
          sourceMap: true
        },
        files: {
          'js/min/all.min.js': [
            'js/plugins.js',
            'js/all.ts.js',
            'bower_components/Stickyfill/src/stickyfill.js',
//            'bower_components/immutable/dist/immutable.js',
//            'bower_components/underscore/underscore.js',
//            'js/bootstrap/carousel.js',
            'js/bootstrap/collapse.js',
            'js/bootstrap/transition.js',
            'js/bootstrap/tab.js',
            'js/bootstrap/dropdown.js',
            'js/bootstrap/button.js'
          ]
        }
      },
      dist: {
        options: {
          sourceMapIncludeSources: false,
          sourceMap: false
        },
        files: {
          'js/min/all.min.js': [
            'js/plugins.js',
            'js/all.ts.js',
            'bower_components/Stickyfill/src/stickyfill.js',
//            'bower_components/immutable/dist/immutable.js',
//            'bower_components/underscore/underscore.js',
//            'js/bootstrap/carousel.js',
            'js/bootstrap/collapse.js',
            'js/bootstrap/transition.js',
            'js/bootstrap/tab.js',
            'js/bootstrap/dropdown.js',
            'js/bootstrap/button.js'
          ]
        }
      }
    }
  });

  grunt.registerTask('dev', function(target) {
    grunt.task.run([
      'typescript:dev',
      'uglify:dev',
      'compass:dev',
      'jekyll:dev',
//      'validation',
//      'htmllint:dev',
      'connect:server',
      'checkPages:dev',
      'watch'
    ]);
  });
  grunt.registerTask('build', function(target) {
    grunt.task.run([
      'clean',
      'typescript:dist',
      'uglify:dist',
      'compass:dist',
      'jekyll:dist',
      'validation',
      'htmllint:dist'
//      'checkPages:dev'
    ]);
  });
  grunt.registerTask('dist', function(target) {
    // dist is an alias for build
    grunt.task.run(['build']);
  });

}
<|endoftext|>


<commit_before>module.exports = function (grunt) {
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		concat: {
			options: {
			    separator: '\n\n'
			},
			youtyping: {
				src: ['src/control.js', 'src/util.js'],
				dest: 'youtyping.js',
				options: {
					banner: '/* youtyping.js <%= grunt.template.today("mm-dd-yyyy") %> */\n\n(function(exports){\n',
					footer: '\n\nexports.YouTyping = YouTyping;\n}(typeof window === \'undefined\' ? module.exports : window));'
				}
			},
			screen: {
				src: ['src/screen.js', 'src/util.js'],
				dest: 'youtyping-screen.js',
				options: {
					banner: '/* youtyping-screen.js <%= grunt.template.today("mm-dd-yyyy") %> */\n\n(function(exports){\n',
					footer: '\n\nexports.Screen = Screen;\n}(typeof window === \'undefined\' ? module.exports : window));'
				}
			}
		},
		uglify: {
			youtyping: {
				options: {
					banner: '/* youtyping.js <%= grunt.template.today("mm-dd-yyyy") %> */\n'
				},
				files: {
					'youtyping.min.js': ['<%= concat.youtyping.dest %>']
				},
				options: {
					sourceMap: true
				}
			},
			screen: {
				options: {
					banner: '/* youtyping-screen.js <%= grunt.template.today("mm-dd-yyyy") %> */\n'
				},
				files: {
					'youtyping-screen.min.js': ['<%= concat.screen.dest %>']
				},
				options: {
					sourceMap: true
				}
			}
		},
		jshint: {
			options: {
				camelcase: true,
				curly: true, // no more GOTO FAIL ;)
				eqeqeq: true,
				es3: true,
				forin: true,
				newcap: true,
				nonbsp: true,
				quotmark: true
			},
			src: {
				src: ['src/*.js']
			},
			build: {
				src: ['youtyping.js', 'youtyping-screen.js'],
				options: {
					undef: true,
					browser: true,
					node: true,
					jquery: true,
					devel: true,
					globals: {
						// YouTube Iframe Player API
						YT: false,
						// paper.js
						paper: false,
						// YouTyping interfaces
						YouTyping: true,
						Screen: true
					}
				}
			}
		},
		connect: {
			server: {
				options: {
					port: 8080,
					debug: true,
					keepalive: true,
					open: 'http://localhost:8080/sample/'
				}
			}
		}
	});

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

	grunt.registerTask('default', ['concat', 'jshint', 'uglify']);
	grunt.registerTask('debug', ['concat', 'jshint', 'uglify', 'connect']);
};
<commit_msg>Restrict the usage of globals<commit_after>module.exports = function (grunt) {
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		concat: {
			options: {
			    separator: '\n\n'
			},
			youtyping: {
				src: ['src/control.js', 'src/util.js'],
				dest: 'youtyping.js',
				options: {
					banner: '/* youtyping.js <%= grunt.template.today("mm-dd-yyyy") %> */\n\n(function(exports){\n',
					footer: '\n\nexports.YouTyping = YouTyping;\n}(typeof window === \'undefined\' ? module.exports : window));'
				}
			},
			screen: {
				src: ['src/screen.js', 'src/util.js'],
				dest: 'youtyping-screen.js',
				options: {
					banner: '/* youtyping-screen.js <%= grunt.template.today("mm-dd-yyyy") %> */\n\n(function(exports){\n',
					footer: '\n\nexports.Screen = Screen;\n}(typeof window === \'undefined\' ? module.exports : window));'
				}
			}
		},
		uglify: {
			youtyping: {
				options: {
					banner: '/* youtyping.js <%= grunt.template.today("mm-dd-yyyy") %> */\n'
				},
				files: {
					'youtyping.min.js': ['<%= concat.youtyping.dest %>']
				},
				options: {
					sourceMap: true
				}
			},
			screen: {
				options: {
					banner: '/* youtyping-screen.js <%= grunt.template.today("mm-dd-yyyy") %> */\n'
				},
				files: {
					'youtyping-screen.min.js': ['<%= concat.screen.dest %>']
				},
				options: {
					sourceMap: true
				}
			}
		},
		jshint: {
			options: {
				camelcase: true,
				curly: true, // no more GOTO FAIL ;)
				eqeqeq: true,
				es3: true,
				forin: true,
				newcap: true,
				nonbsp: true,
				quotmark: true
			},
			src: {
				src: ['src/*.js']
			},
			youtyping: {
				src: ['youtyping.js'],
				options: {
					undef: true,
					browser: true,
					node: true,
					jquery: true,
					devel: true,
					globals: {
						// YouTube Iframe Player API
						YT: false,
						// paper.js
						paper: false
					}
				}
			},
			screen: {
				src: ['youtyping-screen.js'],
				options: {
					undef: true,
					browser: true,
					node: true,
					jquery: true,
					devel: true,
					globals: {
						// YouTube Iframe Player API
						YT: false,
						// paper.js
						paper: false,
						// YouTyping interfaces
						YouTyping: true
					}
				}
			}
		},
		connect: {
			server: {
				options: {
					port: 8080,
					debug: true,
					keepalive: true,
					open: 'http://localhost:8080/sample/'
				}
			}
		}
	});

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

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