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

exports = module.exports = function (grunt) {

  var config = grunt.initConfig({
    clean: {
      docs: {
        src: ['docs']
      },
      example: {
        src: ['example/components']
      },
      test: {
        src: ['coverage']
      }
    },
    karma: {
      unit: {
        configFile: 'config/karma.conf.js'
      },
      e2e: {
        configFile: 'config/karma-e2e.conf.js'
      }
    },
    server: {
      testMode: false,
      port: 3000
    },
    jshint: {
      all: ['Gruntfile.js', 'server.js', 'js/*.js', 'test/**/*.js', 'config/*.js', 'example/*.js']
    },
    docs: {
      all: {
        src: ['README.md', 'js/angular-prevent-default.js']
      }
    }
  });

  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');

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

  grunt.registerTask('bootstrap', ['doc', 'bootstrap-example']);

  grunt.registerTask('default', ['jshint', 'doc', 'bootstrap-example', 'test']);

  grunt.registerTask('test', 'Run all tests', ['test:unit', 'test:e2e']);

  grunt.registerTask('test:unit', 'Runs all unit tests with PhantomJS', function () {
    grunt.task.run('karma:unit');
  });

  grunt.registerTask('test:e2e', 'Runs all end to end tests with Chrome', function () {
    config.server.testMode = true;
    grunt.task.run('server');
    grunt.task.run('karma:e2e');
  });

  grunt.registerTask('cont', ['continuous:unit']);
  grunt.registerTask('cont:unit', ['continuous:unit']);
  grunt.registerTask('continuous', ['continuous:unit']);
  grunt.registerTask('continuous:unit', 'Runs all unit tests continuously with PhantomJS', function () {
    config.karma.unit.singleRun = false;
    config.karma.unit.autoWatch = true;
    grunt.task.run('karma:unit');
  });

  grunt.registerTask('cont:e2e', ['continuous:e2e']);
  grunt.registerTask('continuous:e2e', 'Runs all end to end tests continuously with Chrome', function () {
    config.karma.e2e.singleRun = false;
    config.karma.e2e.autoWatch = true;
    config.server.testMode = true;
    grunt.task.run('server');
    grunt.task.run('karma:e2e');
  });

  grunt.registerTask('check', 'Check to be sure JS is linted and app is tested', ['jshint', 'test']);

  grunt.registerTask('server', 'Run the example server', function () {
    var server, done,
      start = require('./server.js');

    server = start(config.server.port);

    if (!config.server.testMode) {
      done = this.async();
      server.on('close', done);
    }
  });

  // Generate documentation
  grunt.registerMultiTask('docs', 'Generate documentation', function () {
    var done = this.async();

    var child = grunt.util.spawn({
      cmd: path.resolve('./node_modules/.bin/docco'),
      grunt: false,
      args: this.filesSrc
    }, function (error, result, code) {
      grunt.log.ok('Generated documentation at ./docs/');
      done();
    });

    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
  });

  grunt.registerTask('doc', ['docs'])

  // Bootstrap example
  grunt.registerTask('bootstrap-example', 'Bootstrap example', function () {
    var done = this.async();

    grunt.file.setBase('./example');

    var child = grunt.util.spawn({
      cmd: path.resolve('../node_modules/.bin/bower'),
      grunt: false,
      args: ['install']
    }, function (error, result, code) {
      grunt.log.ok('Bootstrapped ./example/');
      done();
    });

    grunt.file.setBase('../');

    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
  });
};
<commit_msg>Fix linting<commit_after>var path = require('path');

exports = module.exports = function (grunt) {

  var config = grunt.initConfig({
    clean: {
      docs: {
        src: ['docs']
      },
      example: {
        src: ['example/components']
      },
      test: {
        src: ['coverage']
      }
    },
    karma: {
      unit: {
        configFile: 'config/karma.conf.js'
      },
      e2e: {
        configFile: 'config/karma-e2e.conf.js'
      }
    },
    server: {
      testMode: false,
      port: 3000
    },
    jshint: {
      all: ['Gruntfile.js', 'server.js', 'js/*.js', 'test/**/*.js', 'config/*.js', 'example/*.js']
    },
    docs: {
      all: {
        src: ['README.md', 'js/angular-prevent-default.js']
      }
    }
  });

  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');

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

  grunt.registerTask('bootstrap', ['doc', 'bootstrap-example']);

  grunt.registerTask('default', ['jshint', 'doc', 'bootstrap-example', 'test']);

  grunt.registerTask('test', 'Run all tests', ['test:unit', 'test:e2e']);

  grunt.registerTask('test:unit', 'Runs all unit tests with PhantomJS', function () {
    grunt.task.run('karma:unit');
  });

  grunt.registerTask('test:e2e', 'Runs all end to end tests with Chrome', function () {
    config.server.testMode = true;
    grunt.task.run('server');
    grunt.task.run('karma:e2e');
  });

  grunt.registerTask('cont', ['continuous:unit']);
  grunt.registerTask('cont:unit', ['continuous:unit']);
  grunt.registerTask('continuous', ['continuous:unit']);
  grunt.registerTask('continuous:unit', 'Runs all unit tests continuously with PhantomJS', function () {
    config.karma.unit.singleRun = false;
    config.karma.unit.autoWatch = true;
    grunt.task.run('karma:unit');
  });

  grunt.registerTask('cont:e2e', ['continuous:e2e']);
  grunt.registerTask('continuous:e2e', 'Runs all end to end tests continuously with Chrome', function () {
    config.karma.e2e.singleRun = false;
    config.karma.e2e.autoWatch = true;
    config.server.testMode = true;
    grunt.task.run('server');
    grunt.task.run('karma:e2e');
  });

  grunt.registerTask('check', 'Check to be sure JS is linted and app is tested', ['jshint', 'test']);

  grunt.registerTask('server', 'Run the example server', function () {
    var server, done,
      start = require('./server.js');

    server = start(config.server.port);

    if (!config.server.testMode) {
      done = this.async();
      server.on('close', done);
    }
  });

  // Generate documentation
  grunt.registerMultiTask('docs', 'Generate documentation', function () {
    var done = this.async();

    var child = grunt.util.spawn({
      cmd: path.resolve('./node_modules/.bin/docco'),
      grunt: false,
      args: this.filesSrc
    }, function (error, result, code) {
      grunt.log.ok('Generated documentation at ./docs/');
      done();
    });

    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
  });

  grunt.registerTask('doc', ['docs']);

  // Bootstrap example
  grunt.registerTask('bootstrap-example', 'Bootstrap example', function () {
    var done = this.async();

    grunt.file.setBase('./example');

    var child = grunt.util.spawn({
      cmd: path.resolve('../node_modules/.bin/bower'),
      grunt: false,
      args: ['install']
    }, function (error, result, code) {
      grunt.log.ok('Bootstrapped ./example/');
      done();
    });

    grunt.file.setBase('../');

    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
  });
};
<|endoftext|>


<commit_before>/*!
 * Gruntfile.js - build script
 *
 * Copyright (c) 2013-2014 Matthew A. Miller
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

module.exports = function(grunt) {
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-nodeunit");
    grunt.loadNpmTasks("grunt-jsdoc");
    grunt.loadNpmTasks("grunt-shell");
    grunt.loadNpmTasks("grunt-express");

    grunt.initConfig({
        jsdoc: {
            all: {
                src: [
                    "README.md",
                    "index.js",
                    "pbkdf2.js",
                    "plain.js",
                    "scram-sha1.js",
                    "lib/*.js"
                ],
                dest: "doc",
                options: {
                    template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
                    configure: "jsdoc.json"
                }
            }
        },
        nodeunit: {
            all: ["test/index.js"],
            options: {
                reporter: "default"
            }
        },
        shell: {
            cover: {
                command: "./node_modules/.bin/istanbul" +
                         " cover" +
                         " --report html" +
                         " ./node_modules/.bin/nodeunit test/index.js",
                options: {
                    stdout: true,
                    stderr: true
                }
            }
        },
        express: {
            nodeunit: {
                options: {
                    port: 12676,
                    hostname: "localhost",
                    bases: "coverage",
                    livereload: 35759,
                    open: "http://localhost:<%= express.nodeunit.options.port%>/"
                }
            },
            jsdoc: {
                options: {
                    port: 12677,
                    hostname: "localhost",
                    bases: "doc",
                    livereload: 35758,
                    open: "http://localhost:<%= express.jsdoc.options.port%>/"
                }
            }
        },
        watch: {
            nodeunit: {
                files: [ "!Gruntfile.js", "*.js", "lib/***/.js", "test/**/*.js" ],
                tasks: [ "shell:cover" ],
                options: {
                    livereload: 35759
                }
            },
            jsdoc: {
                files: [ "!Gruntfile.js", "*.js", "lib/*.js" ],
                tasks: [ "jsdoc:all" ],
                options: {
                    livereload: 35758
                }
            }
        },
        ci: {
            doc: [ "jsdoc:all", "express:jsdoc", "watch:jsdoc" ],
            test: [ "shell:cover", "express:nodeunit", "watch:nodeunit" ]
        },
        clean: {
            coverage: [ "coverage" ]
        }
    });

    grunt.registerTask("doc", ["jsdoc:all"]);
    grunt.registerTask("test", ["shell:cover"]);
    grunt.registerTask("coverage", ["shell:cover"]);
    grunt.registerMultiTask("ci", function() {
        grunt.task.run(this.data);
    });

    grunt.registerTask("default", ["test", "doc"]);
};
<commit_msg>Grunt reflecting reality<commit_after>/*!
 * Gruntfile.js - build script
 *
 * Copyright (c) 2013-2014 Matthew A. Miller
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

module.exports = function(grunt) {
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-nodeunit");
    grunt.loadNpmTasks("grunt-jsdoc");
    grunt.loadNpmTasks("grunt-shell");
    grunt.loadNpmTasks("grunt-express");

    grunt.initConfig({
        jsdoc: {
            all: {
                src: [
                    "README.md",
                    "index.js",
                    "lib/*.js",
                    "mechanisms/*.js"
                ],
                dest: "doc",
                options: {
                    template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
                    configure: "jsdoc.json"
                }
            }
        },
        nodeunit: {
            all: ["test/index.js"],
            options: {
                reporter: "default"
            }
        },
        shell: {
            cover: {
                command: "./node_modules/.bin/istanbul" +
                         " cover" +
                         " --report html" +
                         " ./node_modules/.bin/nodeunit test/index.js",
                options: {
                    stdout: true,
                    stderr: true
                }
            }
        },
        express: {
            nodeunit: {
                options: {
                    port: 12676,
                    hostname: "localhost",
                    bases: "coverage",
                    livereload: 35759,
                    open: "http://localhost:<%= express.nodeunit.options.port%>/"
                }
            },
            jsdoc: {
                options: {
                    port: 12677,
                    hostname: "localhost",
                    bases: "doc",
                    livereload: 35758,
                    open: "http://localhost:<%= express.jsdoc.options.port%>/"
                }
            }
        },
        watch: {
            nodeunit: {
                files: [ "index.js",
                         "lib/***/.js",
                         "mechanisms/**/*.js",
                         "test/**/*.js" ],
                tasks: [ "shell:cover" ],
                options: {
                    livereload: 35759
                }
            },
            jsdoc: {
                files: [ "index.js",
                         "lib/*.js",
                         "mechanisms/*.js" ],
                tasks: [ "jsdoc:all" ],
                options: {
                    livereload: 35758
                }
            }
        },
        ci: {
            doc: [ "jsdoc:all", "express:jsdoc", "watch:jsdoc" ],
            test: [ "shell:cover", "express:nodeunit", "watch:nodeunit" ]
        },
        clean: {
            coverage: [ "coverage" ]
        }
    });

    grunt.registerTask("doc", ["jsdoc:all"]);
    grunt.registerTask("test", ["shell:cover"]);
    grunt.registerTask("coverage", ["shell:cover"]);
    grunt.registerMultiTask("ci", function() {
        grunt.task.run(this.data);
    });

    grunt.registerTask("default", ["test", "doc"]);
};
<|endoftext|>


<commit_before>// Generated on 2014-05-12 using generator-angular 0.8.0
'use strict';

module.exports = function (grunt) {

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

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

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

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

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

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729,
                middleware: function (connect, options) {
                    if (!Array.isArray(options.base)) {
                        options.base = [options.base];
                    }

                    // Setup the proxy
                    var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

                    // Serve static files.
                    options.base.forEach(function(base) {
                        middlewares.push(connect.static(base));
                    });

                    // Make directory browse-able.
                    var directory = options.directory || options.base[options.base.length - 1];
                    middlewares.push(connect.directory(directory));

                    return middlewares;
                }
            },
            proxies: [{
                context: '/api/',
                host: '127.0.0.1',
                port: 8080
            }, {
                context: '/config.js',
                host: '127.0.0.1',
                port: 8080
            }],
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= yeoman.app %>'
                    ]
                }
            },
            dist: {
                options: {
                    base: '<%= yeoman.dist %>'
                }
            }
        },

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

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

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

        // Automatically inject Bower components into the app
        bowerInstall: {
            sass: {
                src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: '<%= yeoman.app %>/bower_components/'
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/fonts',
                relativeAssets: false,
                assetCacheBuster: false,
                raw: 'Sass::Script::Number.precision = 10\n'
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/client/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },

        html2js: {
            options: {
                base: 'app',
                htmlmin: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeComments: true,
                    removeEmptyAttributes: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true
                }
            },
            main: {
                src: ['<%= yeoman.app %>/views/{*,**/*}.html'],
                dest: '.tmp/scripts/templates.js'
            }
        },

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

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

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

        // The following *-min tasks produce minified files in the dist folder
        cssmin: {
            options: {
                root: '<%= yeoman.app %>'
            }
        },

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

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

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

        // ngmin tries to make the code safe for minification automatically by
        // using the Angular long form for dependency injection. It doesn't work on
        // things like resolve or inject so those have to be done manually.
        ngmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/concat/scripts',
                        src: '*.js',
                        dest: '.tmp/concat/scripts'
                    }
                ]
            }
        },

        uglify: {
            options: {
                mangle: false
            }
        },

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

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

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

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

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

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

    grunt.registerTask('default', [
        'newer:jshint',
        'build'
    ]);
};
<commit_msg>Enable jshint for server and shared files.<commit_after>// Generated on 2014-05-12 using generator-angular 0.8.0
'use strict';

module.exports = function (grunt) {

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

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

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

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

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

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729,
                middleware: function (connect, options) {
                    if (!Array.isArray(options.base)) {
                        options.base = [options.base];
                    }

                    // Setup the proxy
                    var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

                    // Serve static files.
                    options.base.forEach(function(base) {
                        middlewares.push(connect.static(base));
                    });

                    // Make directory browse-able.
                    var directory = options.directory || options.base[options.base.length - 1];
                    middlewares.push(connect.directory(directory));

                    return middlewares;
                }
            },
            proxies: [{
                context: '/api/',
                host: '127.0.0.1',
                port: 8080
            }, {
                context: '/config.js',
                host: '127.0.0.1',
                port: 8080
            }],
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= yeoman.app %>'
                    ]
                }
            },
            dist: {
                options: {
                    base: '<%= yeoman.dist %>'
                }
            }
        },

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

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

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

        // Automatically inject Bower components into the app
        bowerInstall: {
            sass: {
                src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: '<%= yeoman.app %>/bower_components/'
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/fonts',
                relativeAssets: false,
                assetCacheBuster: false,
                raw: 'Sass::Script::Number.precision = 10\n'
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/client/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },

        html2js: {
            options: {
                base: 'app',
                htmlmin: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeComments: true,
                    removeEmptyAttributes: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true
                }
            },
            main: {
                src: ['<%= yeoman.app %>/views/{*,**/*}.html'],
                dest: '.tmp/scripts/templates.js'
            }
        },

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

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

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

        // The following *-min tasks produce minified files in the dist folder
        cssmin: {
            options: {
                root: '<%= yeoman.app %>'
            }
        },

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

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

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

        // ngmin tries to make the code safe for minification automatically by
        // using the Angular long form for dependency injection. It doesn't work on
        // things like resolve or inject so those have to be done manually.
        ngmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/concat/scripts',
                        src: '*.js',
                        dest: '.tmp/concat/scripts'
                    }
                ]
            }
        },

        uglify: {
            options: {
                mangle: false
            }
        },

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

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

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

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

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

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

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


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

    // https://github.com/gruntjs/grunt-contrib-jasmine
    grunt.loadNpmTasks('grunt-contrib-jasmine');
    // https://github.com/grunt-ts/grunt-ts
    grunt.loadNpmTasks('grunt-ts');
    // https://github.com/gruntjs/grunt-contrib-jshint
    grunt.loadNpmTasks('grunt-contrib-jshint');
    // https://github.com/palantir/grunt-tslint
    grunt.loadNpmTasks('grunt-tslint');

    grunt.initConfig({
        ts: {
            build: {
                // The source TypeScript files, http://gruntjs.com/configuring-tasks#files
                src: ['src/**/*.ts'],
                // If specified, generate this file that to can use for reference management
                reference: './src/_reference.ts',
                // If specified, the generate JavaScript files are placed here. Only works if out is not specified
                outDir: 'bin',
                // Use to override the default options, http://gruntjs.com/configuring-tasks#options
                options: {
                    // 'es3' (default) | 'es5'
                    target: 'es3',
                    // 'amd' (default) | 'commonjs'
                    module: 'commonjs',
                    // true (default) | false
                    sourceMap: false,
                    // true | false (default)
                    declaration: false,
                    // true (default) | false
                    removeComments: true
                },
            },
            test: {
                // The source TypeScript files, http://gruntjs.com/configuring-tasks#files
                src: ['test/**/*.ts'],
                options: {
                    sourceMap: true,
                },
            }
        },
        jasmine: {
            pivotal: {
                src: 'src/**/*.js',
                options: {
                    specs: 'test/specs/*Spec.js',
                    helpers: 'test/specs/*Helper.js'
                }
            }
        },
        jshint: {
            all: ['Gruntfile.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },
        tslint: {
            options: {
                configuration: grunt.file.readJSON('tslintrc.json')
            },
            all: {
                src: ['app/**/*.ts', 'test/**/*.ts']
            }
        }
    });

    grunt.registerTask('check-code-style', ['jshint:all', 'tslint:all']);
    grunt.registerTask('build', ['ts:build', 'ts:test']);
    grunt.registerTask('test', ['jasmine:pivotal']);
    grunt.registerTask('default', ['check-code-style', 'build', 'test']);
};<commit_msg>adjust grunt comands<commit_after>module.exports = function(grunt) {
    'use strict';

    // https://github.com/gruntjs/grunt-contrib-jasmine
    grunt.loadNpmTasks('grunt-contrib-jasmine');
    // https://github.com/grunt-ts/grunt-ts
    grunt.loadNpmTasks('grunt-ts');
    // https://github.com/gruntjs/grunt-contrib-jshint
    grunt.loadNpmTasks('grunt-contrib-jshint');
    // https://github.com/palantir/grunt-tslint
    grunt.loadNpmTasks('grunt-tslint');

    grunt.initConfig({
        ts: {
            build: {
                // The source TypeScript files, http://gruntjs.com/configuring-tasks#files
                src: ['src/**/*.ts'],
                // If specified, generate this file that to can use for reference management
                reference: './src/_reference.ts',
                // If specified, the generate JavaScript files are placed here. Only works if out is not specified
                outDir: 'bin',
                // Use to override the default options, http://gruntjs.com/configuring-tasks#options
                options: {
                    // 'es3' (default) | 'es5'
                    target: 'es3',
                    // 'amd' (default) | 'commonjs'
                    module: 'commonjs',
                    // true (default) | false
                    sourceMap: false,
                    // true | false (default)
                    declaration: false,
                    // true (default) | false
                    removeComments: true
                },
            },
            test: {
                // The source TypeScript files, http://gruntjs.com/configuring-tasks#files
                src: ['test/**/*.ts'],
                options: {
                    sourceMap: true,
                },
            }
        },
        jasmine: {
            pivotal: {
                src: 'src/**/*.js',
                options: {
                    specs: 'test/specs/*Spec.js',
                    helpers: 'test/specs/*Helper.js'
                }
            }
        },
        jshint: {
            all: ['Gruntfile.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },
        tslint: {
            options: {
                configuration: grunt.file.readJSON('tslintrc.json')
            },
            all: {
                src: ['app/**/*.ts', 'test/**/*.ts']
            }
        }
    });

    grunt.registerTask('check-code-style', ['jshint:all', 'tslint:all']);
    grunt.registerTask('build', ['ts:build', 'ts:test']);
    grunt.registerTask('test', ['check-code-style', 'build', 'jasmine:pivotal']);
    grunt.registerTask('default', ['test']);
};<|endoftext|>


<commit_before>/*jshint node:true*/
/*global module:false*/
module.exports = function(grunt) {
  "use strict";

  var fs = require("fs"),
      devopts;

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON("package.json"),
    banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
      "<%= grunt.template.today(\"yyyy-mm-dd\") %>\n" +
      "<%= pkg.homepage ? \"* \" + pkg.homepage + \"\\n\" : \"\" %>" +
      "* Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %>;" +
      " Licensed <%= _.pluck(pkg.licenses, \"type\").join(\", \") %> */\n",
    // Task configuration.
    prompt: {
        devopts: {
            options: {
                questions: [
                    {
                        config: "tangeloPath",
                        type: "input",
                        message: "Tangelo command?",
                        default: "tangelo",
                    },

                    {
                        config: "tangeloPort",
                        type: "input",
                        message: "Tangelo port?",
                        default: "8080"
                    }
                ]
            }
        }
    },
    version: {
        src: ["lib/core/core.js"]
    },
    cleanup: {
        dist: ["dist"],
        dev: ["node_modules"]
    },
    concat: {
      options: {
        banner: "<%= banner %>",
        stripBanners: true
      },
      dist: {
        src: ["lib/**/*.js"],
        dest: "dist/<%= pkg.name %>.js"
      }
    },
    uglify: {
      options: {
        banner: "<%= banner %>"
      },
      dist: {
        src: "<%= concat.dist.dest %>",
        dest: "dist/<%= pkg.name %>.min.js"
      }
    },
    jshint: {
      options: {
        // Enforcing options (for strict checking, should be true by default;
        // set to false indicates departure from this policy).
        bitwise: true,
        camelcase: true,
        curly: true,
        eqeqeq: true,
        forin: true,
        immed: true,
        latedef: true,
        newcap: true,
        noempty: false,
        nonbsp: true,
        nonew: true,
        plusplus: false,
        quotmark: "double",
        undef: true,
        unused: true,
        strict: true,
        maxparams: false,
        maxdepth: false,
        maxstatements: false,
        maxcomplexity: false,
        maxlen: false,

        // Relaxing options (for strict checking, should be false by
        // default; set to true indicates departure from this policy).
        eqnull: true,

        // Environment options.
        //browser: true,

        // Globals.
        globals: {}
      },
      gruntfile: {
        src: "Gruntfile.js"
      },
      libTest: {
        src: ["lib/**/*.js", "test/**/*.js"]
      }
    },
    qunitTests: {
      options: {
        httpBase: "http://localhost:8080"
      },
      files: ["test/**/*.html"]
    },
    watch: {
      gruntfile: {
        files: "<%= jshint.gruntfile.src %>",
        tasks: ["jshint:gruntfile"]
      },
      libTest: {
        files: "<%= jshint.lib_test.src %>",
        tasks: ["jshint:libTest", "qunit"]
      }
    }
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks("grunt-continue");
  grunt.loadNpmTasks("grunt-prompt");
  grunt.loadNpmTasks("grunt-version");
  grunt.loadNpmTasks("grunt-contrib-concat");
  grunt.loadNpmTasks("grunt-contrib-uglify");
  grunt.loadNpmTasks("grunt-contrib-qunit");
  grunt.loadNpmTasks("grunt-contrib-jshint");
  grunt.loadNpmTasks("grunt-contrib-watch");
  grunt.loadNpmTasks("grunt-contrib-clean");

  // Default task.
  grunt.registerTask("default", ["version", "jshint", "qunit", "concat", "uglify"]);

  // Tangelo launch/kill task.
  (function () {
    var tangelo = null,
        stopping,
        output = [];

    grunt.registerTask("tangelo", "Starts/stops a Tangelo server instance.", function (op) {
      var done,
          fragment = null;

      if (op === "start") {
        if (tangelo) {
          grunt.fail.warn("Tangelo is running already.");
        }

        stopping = false;

        done = this.async();

        tangelo = grunt.util.spawn({
          cmd: "tangelo",
          args: [
            "--port", "8080",
            "--root", "."
          ]
        }, function () {});

        tangelo.stderr.setEncoding("utf8");

        tangelo.stderr.on("data", function (chunk) {
          var complete = chunk.slice(-1) === "\n",
              lines,
              i,
              n;

          if (fragment) {
            chunk = fragment + chunk;
            fragment = null;
          }

          lines = chunk.split("\n");
          n = complete ? lines.length : lines.length - 1;
          for (i = 0; i < n; i++) {
            if (!stopping && lines[i].indexOf("ENGINE Bus STARTED") !== -1) {
              console.log("Tangelo started with PID " + tangelo.pid);
              done();
            }

            output.push(lines[i]);
          }

          if (!complete) {
            fragment = lines[lines.length - 1];
          }
        });

        tangelo.stderr.on("end", function () {
          if (stopping) {
              return;
          }
          grunt.fail.fatal("Tangelo could not be started\n" + output.join("\n"));
        });
      } else if (op === "stop") {
        if (!tangelo) {
          grunt.fail.warn("Tangelo is not running");
        }

        stopping = true;
        done = this.async();

        tangelo.kill();

        tangelo.stderr.on("end", function () {
          done();
        });

        setTimeout(function () {
          grunt.fail.warn("Could not kill Tangelo\n" + output.join("\n"));
        }, 10000);
      } else {
        grunt.fail.warn("Unknown argument: '" + op + "'");
      }
    });
  }());

  // Test task.  Start the Tangelo server, run the tests, then shut the server
  // down.
  grunt.renameTask("qunit", "qunitTests");
  grunt.registerTask("qunit", [
    "devopts",
    "tangelo:start",
    "continueOn",
    "qunitTests",
    "continueOff",
    "tangelo:stop"
  ]);

  grunt.registerTask("devopts", "Read developer options from devopts.json, or create it if it doesn't exist", function () {
      var text;

      try {
          text = fs.readFileSync("devopts.json", {encoding: "utf8"});
          devopts = JSON.parse(text);
      } catch (e) {
          grunt.task.run("gendevopts");
          grunt.task.run("devopts");
      }
  });

  grunt.registerTask("gendevopts", "Write developer options out to disk", function () {
      var text;

      // If there is no config, then schedule the prompt task, followed by a
      // retry of the current task, then bail.
      if (!grunt.config("tangeloPath")) {
          grunt.task.run("prompt:devopts");
          grunt.task.run("gendevopts");
          return;
      }

      // Build a devopts object from the config values.
      text = JSON.stringify({
          tangeloPath: grunt.config("tangeloPath"),
          tangeloPort: parseInt(grunt.config("tangeloPort"))
      }, null, 4) + "\n";

      // Serialize it to disk.
      try {
          fs.writeFileSync("devopts.json", text);
      } catch (e) {
          grunt.fail.warn("Could not write devopts.json\n" + e);
      }
  });

  // Clean task.  To prevent "grunt clean" from deleting the node_modules
  // directory (as it would by default), we're renaming the task to "cleanup",
  // then installing a better behaved default "clean" task.
  grunt.renameTask("clean", "cleanup");
  grunt.registerTask("clean", ["clean:dist"]);
  grunt.registerTask("clean:dist", ["cleanup:dist"]);
  grunt.registerTask("clean:dev", ["cleanup:dev"]);
  grunt.registerTask("clean:all", ["clean:dist", "clean:dev"]);
};
<commit_msg>Better reporting<commit_after>/*jshint node:true*/
/*global module:false*/
module.exports = function(grunt) {
  "use strict";

  var fs = require("fs"),
      devopts;

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON("package.json"),
    banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
      "<%= grunt.template.today(\"yyyy-mm-dd\") %>\n" +
      "<%= pkg.homepage ? \"* \" + pkg.homepage + \"\\n\" : \"\" %>" +
      "* Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %>;" +
      " Licensed <%= _.pluck(pkg.licenses, \"type\").join(\", \") %> */\n",
    // Task configuration.
    prompt: {
        devopts: {
            options: {
                questions: [
                    {
                        config: "tangeloPath",
                        type: "input",
                        message: "Tangelo command?",
                        default: "tangelo",
                    },

                    {
                        config: "tangeloPort",
                        type: "input",
                        message: "Tangelo port?",
                        default: "8080"
                    }
                ]
            }
        }
    },
    version: {
        src: ["lib/core/core.js"]
    },
    cleanup: {
        dist: ["dist"],
        dev: ["node_modules"]
    },
    concat: {
      options: {
        banner: "<%= banner %>",
        stripBanners: true
      },
      dist: {
        src: ["lib/**/*.js"],
        dest: "dist/<%= pkg.name %>.js"
      }
    },
    uglify: {
      options: {
        banner: "<%= banner %>"
      },
      dist: {
        src: "<%= concat.dist.dest %>",
        dest: "dist/<%= pkg.name %>.min.js"
      }
    },
    jshint: {
      options: {
        // Enforcing options (for strict checking, should be true by default;
        // set to false indicates departure from this policy).
        bitwise: true,
        camelcase: true,
        curly: true,
        eqeqeq: true,
        forin: true,
        immed: true,
        latedef: true,
        newcap: true,
        noempty: false,
        nonbsp: true,
        nonew: true,
        plusplus: false,
        quotmark: "double",
        undef: true,
        unused: true,
        strict: true,
        maxparams: false,
        maxdepth: false,
        maxstatements: false,
        maxcomplexity: false,
        maxlen: false,

        // Relaxing options (for strict checking, should be false by
        // default; set to true indicates departure from this policy).
        eqnull: true,

        // Environment options.
        //browser: true,

        // Globals.
        globals: {}
      },
      gruntfile: {
        src: "Gruntfile.js"
      },
      libTest: {
        src: ["lib/**/*.js", "test/**/*.js"]
      }
    },
    qunitTests: {
      options: {
        httpBase: "http://localhost:8080"
      },
      files: ["test/**/*.html"]
    },
    watch: {
      gruntfile: {
        files: "<%= jshint.gruntfile.src %>",
        tasks: ["jshint:gruntfile"]
      },
      libTest: {
        files: "<%= jshint.lib_test.src %>",
        tasks: ["jshint:libTest", "qunit"]
      }
    }
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks("grunt-continue");
  grunt.loadNpmTasks("grunt-prompt");
  grunt.loadNpmTasks("grunt-version");
  grunt.loadNpmTasks("grunt-contrib-concat");
  grunt.loadNpmTasks("grunt-contrib-uglify");
  grunt.loadNpmTasks("grunt-contrib-qunit");
  grunt.loadNpmTasks("grunt-contrib-jshint");
  grunt.loadNpmTasks("grunt-contrib-watch");
  grunt.loadNpmTasks("grunt-contrib-clean");

  // Default task.
  grunt.registerTask("default", ["version", "jshint", "qunit", "concat", "uglify"]);

  // Tangelo launch/kill task.
  (function () {
    var tangelo = null,
        stopping,
        output = [];

    grunt.registerTask("tangelo", "Starts/stops a Tangelo server instance.", function (op) {
      var done,
          cmdline,
          fragment = null;

      if (op === "start") {
        if (tangelo) {
          grunt.fail.warn("Tangelo is running already.");
        }

        stopping = false;

        done = this.async();

        cmdline = {
            cmd: devopts.tangeloPath,
            args: [
                "--port", devopts.tangeloPort,
                "--root", "."
              ]
        };

        console.log("Starting Tangelo server with: " + cmdline.cmd + " " + cmdline.args.join(" "));
        tangelo = grunt.util.spawn(cmdline, function () {});
        if (!tangelo) {
            grunt.fail.fatal("Could not launch Tangelo");
        }

        tangelo.stderr.setEncoding("utf8");

        tangelo.stderr.on("data", function (chunk) {
          var complete = chunk.slice(-1) === "\n",
              lines,
              i,
              n;

          if (fragment) {
            chunk = fragment + chunk;
            fragment = null;
          }

          lines = chunk.split("\n");
          n = complete ? lines.length : lines.length - 1;
          for (i = 0; i < n; i++) {
            if (!stopping && lines[i].indexOf("ENGINE Bus STARTED") !== -1) {
              console.log("Tangelo started with PID " + tangelo.pid);
              done();
            }

            output.push(lines[i]);
          }

          if (!complete) {
            fragment = lines[lines.length - 1];
          }
        });

        tangelo.stderr.on("end", function () {
          if (stopping) {
              return;
          }
          grunt.fail.fatal("Tangelo could not be started\n" + output.join("\n"));
        });
      } else if (op === "stop") {
        if (!tangelo) {
          grunt.fail.warn("Tangelo is not running");
        }

        stopping = true;
        done = this.async();

        tangelo.kill();

        tangelo.stderr.on("end", function () {
          done();
        });

        setTimeout(function () {
          grunt.fail.warn("Could not kill Tangelo\n" + output.join("\n"));
        }, 10000);
      } else {
        grunt.fail.warn("Unknown argument: '" + op + "'");
      }
    });
  }());

  // Test task.  Start the Tangelo server, run the tests, then shut the server
  // down.
  grunt.renameTask("qunit", "qunitTests");
  grunt.registerTask("qunit", [
    "devopts",
    "tangelo:start",
    "continueOn",
    "qunitTests",
    "continueOff",
    "tangelo:stop"
  ]);

  grunt.registerTask("devopts", "Read developer options from devopts.json, or create it if it doesn't exist", function () {
      var text;

      try {
          text = fs.readFileSync("devopts.json", {encoding: "utf8"});
          devopts = JSON.parse(text);
      } catch (e) {
          grunt.task.run("gendevopts");
          grunt.task.run("devopts");
      }
  });

  grunt.registerTask("gendevopts", "Write developer options out to disk", function () {
      var text;

      // If there is no config, then schedule the prompt task, followed by a
      // retry of the current task, then bail.
      if (!grunt.config("tangeloPath")) {
          grunt.task.run("prompt:devopts");
          grunt.task.run("gendevopts");
          return;
      }

      // Build a devopts object from the config values.
      text = JSON.stringify({
          tangeloPath: grunt.config("tangeloPath"),
          tangeloPort: parseInt(grunt.config("tangeloPort"))
      }, null, 4) + "\n";

      // Serialize it to disk.
      try {
          fs.writeFileSync("devopts.json", text);
      } catch (e) {
          grunt.fail.warn("Could not write devopts.json\n" + e);
      }
  });

  // Clean task.  To prevent "grunt clean" from deleting the node_modules
  // directory (as it would by default), we're renaming the task to "cleanup",
  // then installing a better behaved default "clean" task.
  grunt.renameTask("clean", "cleanup");
  grunt.registerTask("clean", ["clean:dist"]);
  grunt.registerTask("clean:dist", ["cleanup:dist"]);
  grunt.registerTask("clean:dev", ["cleanup:dev"]);
  grunt.registerTask("clean:all", ["clean:dist", "clean:dev"]);
};
<|endoftext|>


<commit_before>describe('pagingDivButtonGroupController', function() {
  var $scope, $controller, miqService, $compile;

  beforeEach(module('ManageIQ'));

  beforeEach(inject(function($rootScope, _$controller_, _miqService_, _$compile_) {
    miqService = _miqService_;
    $scope = $rootScope.$new();
    $compile = _$compile_;

    $scope.newRecord = false;

    $scope.model = "myModel";
    var element = angular.element(
      '<form name="angularForm">' +
      '<input type="text" ng-model="myModel.userid" name="userid"/>' +
      '</form>'
    );
    $compile(element)($scope);
    $scope.$digest();
    angularForm = $scope.angularForm;

    paging_div = angular.element('

');
    angular.element(document.body).append(paging_div);

    $controller = _$controller_('pagingDivButtonGroupController',
      {$scope:     $scope,
       miqService: miqService,
       $compile:   $compile,
       $attrs:     {'pagingDivButtonsId': 'angular_paging_div_buttons'}});
  }));

  afterEach(function(){
    paging_div.remove();
    paging_div = null;
  });

  describe('when form is pristine', function() {
    it('it displays a disabled Save button and a disabled Reset button', function() {
      expect(paging_div[0].childNodes[0].className).not.toContain('ng-hide');
      expect(paging_div[0].childNodes[1].className).toContain('ng-hide');
      expect(paging_div[0].childNodes[2].outerHTML).toContain('disabled="disabled"');
    });
  });

  describe('when form is dirty', function() {
    it('it displays an enabled Save button and an enabled Reset button', function() {
      angularForm.userid.$setViewValue('admin');
      expect(paging_div[0].childNodes[0].className).toContain('ng-hide');
      expect(paging_div[0].childNodes[1].className).not.toContain('ng-hide');
      expect(paging_div[0].childNodes[2].outerHTML).not.toContain('disabled="disabled"');
    });
  });
});
<commit_msg>Fix spec by injecting $timeout<commit_after>describe('pagingDivButtonGroupController', function() {
  var $scope, $controller, miqService, $compile;

  beforeEach(module('ManageIQ'));

  beforeEach(inject(function($rootScope, _$controller_, _miqService_, _$compile_) {
    miqService = _miqService_;
    $scope = $rootScope.$new();
    $compile = _$compile_;

    $scope.newRecord = false;

    $scope.model = "myModel";
    var element = angular.element(
      '<form name="angularForm">' +
      '<input type="text" ng-model="myModel.userid" name="userid"/>' +
      '</form>'
    );
    $compile(element)($scope);
    $scope.$digest();
    angularForm = $scope.angularForm;

    paging_div = angular.element('

');
    angular.element(document.body).append(paging_div);

    $controller = _$controller_('pagingDivButtonGroupController',
      {$scope:     $scope,
       miqService: miqService,
       $compile:   $compile,
       $attrs:     {'pagingDivButtonsId': 'angular_paging_div_buttons'}});
  }));

  afterEach(function(){
    paging_div.remove();
    paging_div = null;
  });

  describe('when form is pristine', function() {
    it('it displays a disabled Save button and a disabled Reset button', inject(function($timeout) {
      $timeout.flush();
      expect(paging_div[0].childNodes[0].className).not.toContain('ng-hide');
      expect(paging_div[0].childNodes[1].className).toContain('ng-hide');
      expect(paging_div[0].childNodes[2].outerHTML).toContain('disabled="disabled"');
    }));
  });

  describe('when form is dirty', function() {
    it('it displays an enabled Save button and an enabled Reset button', inject(function($timeout) {
      $timeout.flush();
      angularForm.userid.$setViewValue('admin');
      expect(paging_div[0].childNodes[0].className).toContain('ng-hide');
      expect(paging_div[0].childNodes[1].className).not.toContain('ng-hide');
      expect(paging_div[0].childNodes[2].outerHTML).not.toContain('disabled="disabled"');
    }));
  });
});
<|endoftext|>


<commit_before>module.exports = function(grunt) {
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');

	grunt.initConfig({
		// Installation directory based on the V-MANIP organization repository:
		installdir: '../WebClient-Framework/app/scripts/vendor/rectangularboxviewer',
		pkg: grunt.file.readJSON('package.json'),
		concat: {
			options: {
				separator: '\n'
			},
			dist: {
				files: {
					'dist/<%= pkg.name %>.debug.js': ['src/viewer.js', 'src/**/*.js'],
					'dist/<%= pkg.name %>-deps.debug.js': ['deps/*.js']
				}
			}
		},
		copy: {
			main: {
				files: [
					{
						flatten: true,
						expand: true,
						src: ['dist/*.js'],
						dest: '<%= installdir %>'
					}
				]
			},
		},

		watch: {
            scripts: {
                files: ['src/**/*.js'],
                tasks: ['default']
            }
        }
	});

    grunt.loadNpmTasks('grunt-contrib-watch');

	grunt.registerTask('default', ['concat', 'copy']);
};
<commit_msg>Adjusted Gruntfile<commit_after>module.exports = function(grunt) {
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');

	grunt.initConfig({
		// Installation directory based on the V-MANIP organization repository:
		installdir: '../WebClient-Framework/app/scripts/vendor/rectangularboxviewer',
		pkg: grunt.file.readJSON('package.json'),
		concat: {
			options: {
				separator: '\n'
			},
			dist: {
				files: {
					'dist/<%= pkg.name %>.debug.js': ['src/viewer.js', 'src/**/*.js'],
					'dist/<%= pkg.name %>-deps.debug.js': ['deps/*.js']
				}
			}
		},
		copy: {
			main: {
				files: [
					{
						flatten: true,
						expand: true,
						src: ['dist/*.js'],
						dest: '<%= installdir %>'
					}
				]
			},
		},

		watch: {
            scripts: {
                files: ['src/**/*.js', 'deps/*.js'],
                tasks: ['default']
            }
        }
	});

    grunt.loadNpmTasks('grunt-contrib-watch');

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


<commit_before>/*
 * grunt-php2html
 * https://github.com/bzoerb/grunt-php2html
 *
 * Copyright (c) 2013 Ben Zörb
 * Licensed under the MIT license.
 */
'use strict';

module.exports = function (grunt) {

	// show elapsed time at the end
	require('time-grunt')(grunt);
	// load all grunt tasks
	require('load-grunt-tasks')(grunt);

	// Project configuration.
	grunt.initConfig({
		jshint: {
			all: [
				'Gruntfile.js',
				'tasks/**/*.js',
				'<%= nodeunit.tests %>'
			],
			options: {
				jshintrc: '.jshintrc'
			}
		},

		// Before generating any new files, remove any previously-created files.
		clean: {
			tests: ['tmp']
		},

        php2htmlclean: { all: { } },

		// Configuration to be run (and then tested).
		php2html: {
			default: {
				options: {
					// relative links should be renamed from .php to .html
					processLinks: true,
                    htmlhintrc: true,
					htmlhint: {}
				},
				files: [
					{expand: true, cwd: 'test/', src: ['**/*.php','!fixtures/error.php','!env/*.php'], dest: 'tmp/default', ext: '.html' }
				]
			},

			'dest-as-target': {
				options: {
					processLinks: false,
					htmlhint: {},
					docroot: 'test'
				},
				files: {
					'tmp/dest-as-target/': ['test/some-other-fixtures/info.php','test/fixtures/index.php']
				}
			},

			'first-error': {
				options: {
					processLinks: false,
					htmlhint: {
						'tag-pair': true
					}
				},
				files: {
					'tmp/only-index/': ['test/fixtures/error.php','test/fixtures/index.php']
				}
			},

			'environment': {
				options: {
					htmlhint: {}
				},
				files: [
					{expand: true, cwd: './', src: ['test/env/*.php'], dest: 'tmp/', ext: '.html' }
				]

			},

			'processTest': {
				options: {
					processLinks: false,
					htmlhint: {},
					process: function(response,callback) {
						callback(':-)');
					}
				},
				files: {
					'tmp/processTest/': ['test/fixtures/index.php']
				}
			},

            'getData': {
                options: {
                    htmlhint: {},
                    getData: {test: 42, arr: [1,2,3,4], obj: {a:1,b:2,c:3}}
                },
                files: {
                    'tmp/data/': ['test/fixtures/get.php']
                }
            }
		},

		// Unit tests.
		nodeunit: {
			tests: ['test/*_test.js']
		}

	});

	// Actually load this plugin's task(s).
	grunt.loadTasks('tasks');

	// Whenever the "test" task is run, first clean the "tmp" dir, then run this
	// plugin's task(s), then test the result.
	grunt.registerTask('test', ['clean','php2html','nodeunit'/*, 'clean'*/]);

	// By default, lint and run all tests.
	grunt.registerTask('default', ['jshint', 'test']);

};
<commit_msg>Update Gruntfile.js<commit_after>/*
 * grunt-php2html
 * https://github.com/bzoerb/grunt-php2html
 *
 * Copyright (c) 2013 Ben Zörb
 * Licensed under the MIT license.
 */
'use strict';

module.exports = function (grunt) {

	// show elapsed time at the end
	require('time-grunt')(grunt);
	// load all grunt tasks
	require('load-grunt-tasks')(grunt);

	// Project configuration.
	grunt.initConfig({
		jshint: {
			all: [
				'Gruntfile.js',
				'tasks/**/*.js',
				'<%= nodeunit.tests %>'
			],
			options: {
				jshintrc: '.jshintrc'
			}
		},

		// Before generating any new files, remove any previously-created files.
		clean: {
			tests: ['tmp']
		},

        php2htmlclean: { all: { } },

		// Configuration to be run (and then tested).
		php2html: {
			default: {
				options: {
					// relative links should be renamed from .php to .html
					processLinks: true,
					htmlhint: false,
				},
				files: [
					{expand: true, cwd: 'test/', src: ['**/*.php','!fixtures/error.php','!env/*.php'], dest: 'tmp/default', ext: '.html' }
				]
			},

			'dest-as-target': {
				options: {
					processLinks: false,
					htmlhint: false,
					docroot: 'test'
				},
				files: {
					'tmp/dest-as-target/': ['test/some-other-fixtures/info.php','test/fixtures/index.php']
				}
			},

			'first-error': {
				options: {
					processLinks: false,
					htmlhint: {
						'tag-pair': true
					}
				},
				files: {
					'tmp/only-index/': ['test/fixtures/error.php','test/fixtures/index.php']
				}
			},

			'environment': {
				options: {
					htmlhint: false,
				},
				files: [
					{expand: true, cwd: './', src: ['test/env/*.php'], dest: 'tmp/', ext: '.html' }
				]

			},

			'processTest': {
				options: {
					processLinks: false,
					htmlhint: false,
					process: function(response,callback) {
						callback(':-)');
					}
				},
				files: {
					'tmp/processTest/': ['test/fixtures/index.php']
				}
			},

            'getData': {
                options: {
                    htmlhint: false,
                    getData: {test: 42, arr: [1,2,3,4], obj: {a:1,b:2,c:3}}
                },
                files: {
                    'tmp/data/': ['test/fixtures/get.php']
                }
            }
		},

		// Unit tests.
		nodeunit: {
			tests: ['test/*_test.js']
		}

	});

	// Actually load this plugin's task(s).
	grunt.loadTasks('tasks');

	// Whenever the "test" task is run, first clean the "tmp" dir, then run this
	// plugin's task(s), then test the result.
	grunt.registerTask('test', ['clean','php2html','nodeunit'/*, 'clean'*/]);

	// By default, lint and run all tests.
	grunt.registerTask('default', ['jshint', 'test']);

};
<|endoftext|>


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

  //Load NPM tasks
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-markdown');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-angular-gettext');
  grunt.loadNpmTasks('grunt-jsdoc');

  // Project Configuration
  grunt.initConfig({
    shell: {
      prod: {
        options: {
          stdout: false,
          stderr: false
        },
        command: 'node ./util/build.js'
      },
      dev: {
        options: {
          stdout: true,
          stderr: true
        },
        command: 'node ./util/build.js -d'
      }
    },
    watch: {
      options: {
        dateFormat: function(time) {
          grunt.log.writeln('The watch finished in ' + time + 'ms at ' + (new Date()).toString());
          grunt.log.writeln('Waiting for more changes...');
        },
      },
      readme: {
        files: ['README.md'],
        tasks: ['markdown']
      },
      scripts: {
        files: [
          'js/models/**/*.js'
        ],
        tasks: ['shell:dev']
      },
      css: {
        files: ['css/src/*.css'],
        tasks: ['cssmin:copay']
      },
      main: {
        files: [
          'js/init.js',
          'js/app.js',
          'js/directives.js',
          'js/filters.js',
          'js/routes.js',
          'js/mobile.js',
          'js/services/*.js',
          'js/controllers/*.js'
        ],
        tasks: ['concat:main']
      },
      config: {
        files: ['config.js'],
        tasks: ['shell:dev', 'concat:main']
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec',
      },
      src: ['test/*.js'],
    },
    markdown: {
      all: {
        files: [{
          expand: true,
          src: 'README.md',
          dest: '.',
          ext: '.html'
        }]
      }
    },
    concat: {
      vendors: {
        src: [
          'lib/mousetrap/mousetrap.min.js',
          'js/shell.js', // shell must be loaded before moment due to the way moment loads in a commonjs env
          'lib/moment/min/moment.min.js',
          'lib/qrcode-generator/js/qrcode.js',
          'lib/underscore/underscore.js',
          'lib/bitcore.js',
          'lib/crypto-js/rollups/sha256.js',
          'lib/crypto-js/rollups/pbkdf2.js',
          'lib/crypto-js/rollups/aes.js',
          'lib/file-saver/FileSaver.js',
          'lib/socket.io-client/socket.io.js',
          'lib/sjcl.js',
          'lib/ios-imagefile-megapixel/megapix-image.js',
          'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js',
          'lib/zeroclipboard/ZeroClipboard.min.js'
        ],
        dest: 'lib/vendors.js'
      },
      angular: {
        src: [
          'lib/angular/angular.min.js',
          'lib/angular-route/angular-route.min.js',
          'lib/angular-moment/angular-moment.js',
          'lib/angular-qrcode/qrcode.js',
          'lib/ng-idle/angular-idle.min.js',
          'lib/angular-foundation/mm-foundation.min.js',
          'lib/angular-foundation/mm-foundation-tpls.min.js',
          'lib/angular-gettext/dist/angular-gettext.min.js'
        ],
        dest: 'lib/angularjs-all.js'
      },
      main: {
        src: [
          'js/app.js',
          'js/directives.js',
          'js/filters.js',
          'js/routes.js',
          'js/services/*.js',
          'js/controllers/*.js',
          'js/translations.js',
          'js/mobile.js', // PLACEHOLDER: CORDOVA SRIPT
          'js/init.js'
        ],
        dest: 'js/copayMain.js'
      }
    },
    cssmin: {
      copay: {
        files: {
          'css/copay.min.css': ['css/src/*.css'],
        }
      },
      vendors: {
        files: {
          'css/vendors.min.css': ['css/foundation.min.css', 'css/foundation-icons.css', 'lib/angular/angular-csp.css']
        }
      }
    },
    uglify: {
      options: {
        mangle: false
      },
      prod: {
        files: {
          'js/copayMain.js': ['js/copayMain.js'],
          'lib/angularjs-all.js': ['lib/angularjs-all.js'],
          'lib/vendors.js': ['lib/vendors.js']
        }
      }
    },
    nggettext_extract: {
      pot: {
        files: {
          'po/template.pot': ['index.html', 'views/*.html', 'views/**/*.html']
        }
      },
    },
    nggettext_compile: {
      all: {
        options: {
          module: 'copayApp'
        },
        files: {
          'js/translations.js': ['po/*.po']
        }
      },
    },
    jsdoc: {
      dist : {
        src: ['js/models/core/*.js'],
        options: {
          destination: 'doc',
          configure: 'jsdoc.conf.json',
          template: './node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
          theme: 'flatly'
        }
      }
    }
  });

  grunt.registerTask('default', ['shell:dev', 'nggettext_compile', 'concat', 'cssmin']);
  grunt.registerTask('prod', ['shell:prod', 'nggettext_compile', 'concat', 'cssmin', 'uglify']);
  grunt.registerTask('translate', ['nggettext_extract']);
  grunt.registerTask('docs', ['jsdoc2md']);
};
<commit_msg>Fixes old version of grunt<commit_after>module.exports = function(grunt) {

  //Load NPM tasks
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-markdown');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-angular-gettext');
  grunt.loadNpmTasks('grunt-jsdoc');

  // Project Configuration
  grunt.initConfig({
    shell: {
      prod: {
        options: {
          stdout: false,
          stderr: false
        },
        command: 'node ./util/build.js'
      },
      dev: {
        options: {
          stdout: true,
          stderr: true
        },
        command: 'node ./util/build.js -d'
      }
    },
    watch: {
      options: {
        dateFormat: function(time) {
          grunt.log.writeln('The watch finished in ' + time + 'ms at ' + (new Date()).toString());
          grunt.log.writeln('Waiting for more changes...');
        },
      },
      readme: {
        files: ['README.md'],
        tasks: ['markdown']
      },
      scripts: {
        files: [
          'js/models/**/*.js'
        ],
        tasks: ['shell:dev']
      },
      css: {
        files: ['css/src/*.css'],
        tasks: ['cssmin:copay']
      },
      main: {
        files: [
          'js/init.js',
          'js/app.js',
          'js/directives.js',
          'js/filters.js',
          'js/routes.js',
          'js/mobile.js',
          'js/services/*.js',
          'js/controllers/*.js'
        ],
        tasks: ['concat:main']
      },
      config: {
        files: ['config.js'],
        tasks: ['shell:dev', 'concat:main']
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec',
      },
      src: ['test/*.js'],
    },
    markdown: {
      all: {
        files: [{
          expand: true,
          src: 'README.md',
          dest: '.',
          ext: '.html'
        }]
      }
    },
    concat: {
      vendors: {
        src: [
          'lib/mousetrap/mousetrap.min.js',
          'js/shell.js', // shell must be loaded before moment due to the way moment loads in a commonjs env
          'lib/moment/min/moment.min.js',
          'lib/qrcode-generator/js/qrcode.js',
          'lib/underscore/underscore.js',
          'lib/bitcore.js',
          'lib/crypto-js/rollups/sha256.js',
          'lib/crypto-js/rollups/pbkdf2.js',
          'lib/crypto-js/rollups/aes.js',
          'lib/file-saver/FileSaver.js',
          'lib/socket.io-client/socket.io.js',
          'lib/sjcl.js',
          'lib/ios-imagefile-megapixel/megapix-image.js',
          'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js',
          'lib/zeroclipboard/ZeroClipboard.min.js'
        ],
        dest: 'lib/vendors.js'
      },
      angular: {
        src: [
          'lib/angular/angular.min.js',
          'lib/angular-route/angular-route.min.js',
          'lib/angular-moment/angular-moment.js',
          'lib/angular-qrcode/qrcode.js',
          'lib/ng-idle/angular-idle.min.js',
          'lib/angular-foundation/mm-foundation.min.js',
          'lib/angular-foundation/mm-foundation-tpls.min.js',
          'lib/angular-gettext/dist/angular-gettext.min.js'
        ],
        dest: 'lib/angularjs-all.js'
      },
      main: {
        src: [
          'js/app.js',
          'js/directives.js',
          'js/filters.js',
          'js/routes.js',
          'js/services/*.js',
          'js/controllers/*.js',
          'js/translations.js',
          'js/mobile.js', // PLACEHOLDER: CORDOVA SRIPT
          'js/init.js'
        ],
        dest: 'js/copayMain.js'
      }
    },
    cssmin: {
      copay: {
        files: {
          'css/copay.min.css': ['css/src/*.css'],
        }
      },
      vendors: {
        files: {
          'css/vendors.min.css': ['css/foundation.min.css', 'css/foundation-icons.css', 'lib/angular/angular-csp.css']
        }
      }
    },
    uglify: {
      options: {
        mangle: false
      },
      prod: {
        files: {
          'js/copayMain.js': ['js/copayMain.js'],
          'lib/angularjs-all.js': ['lib/angularjs-all.js'],
          'lib/vendors.js': ['lib/vendors.js']
        }
      }
    },
    nggettext_extract: {
      pot: {
        files: {
          'po/template.pot': ['index.html', 'views/*.html', 'views/**/*.html']
        }
      },
    },
    nggettext_compile: {
      all: {
        options: {
          module: 'copayApp'
        },
        files: {
          'js/translations.js': ['po/*.po']
        }
      },
    },
    jsdoc: {
      dist : {
        src: ['js/models/core/*.js'],
        options: {
          destination: 'doc',
          configure: 'jsdoc.conf.json',
          template: './node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
          theme: 'flatly'
        }
      }
    }
  });

  grunt.registerTask('default', ['shell:dev', 'nggettext_compile', 'concat', 'cssmin']);
  grunt.registerTask('prod', ['shell:prod', 'nggettext_compile', 'concat', 'cssmin', 'uglify']);
  grunt.registerTask('translate', ['nggettext_extract']);
  grunt.registerTask('docs', ['jsdoc']);
};
<|endoftext|>


<commit_before>/*
 * nuntius
 *
 * Web page instance messenger
 * https://github.com/waltzofpearls/nuntius
 *
 * Copyright (c) 2014 Topbass Labs (topbasslabs.com)
 * Author Waltz.of.Pearls <rollie@topbasslabs.com, rollie.ma@gmail.com>
 */<commit_msg>Added less build task to Gruntfile<commit_after>/*
 * nuntius
 *
 * Web page instance messenger
 * https://github.com/waltzofpearls/nuntius
 *
 * Copyright (c) 2014 Topbass Labs (topbasslabs.com)
 * Author Waltz.of.Pearls <rollie@topbasslabs.com, rollie.ma@gmail.com>
 */

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

    grunt.initConfig({
        less: {
            testing: {
                options: {
                    strictMath: true,
                    compress: false
                },
                src: 'public/stylesheets/style.less',
                dest: 'public/stylesheets/style.css'
            },
            production: {
                options: {
                    strictMath: true,
                    cleancss: true
                },
                src: 'public/stylesheets/style.less',
                dest: 'public/stylesheets/style.css'
            }
        }
    });

    require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
    require('time-grunt')(grunt);

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


<commit_before>var md = require('jstransformer')(require('jstransformer-markdown-it'));
const sdedit = require('./tasks/grunt-sdedit');

module.exports = function (grunt) {

  const sdFiles = grunt.file.expand('src/**/*.sd');

  grunt.loadNpmTasks('grunt-contrib-pug');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-npm');
  sdedit(grunt);

  const watchConfig = {
    options: {
      livereload: true
    },
    sdedit: {
      files: ['src/**/*.sd'],
      tasks: ['sdedit']
    },
    pug: {
      files: ['src/**/*.pug', 'src/**/*.js', 'src/**/*.json'],
      tasks: ['pug']
    },
    js: {
      files: ['javascripts/**/*.js']
    },
    css: {
      files: ['stylesheets/**/*.css']
    }
  };

  const config = {
    clean: {
      html: ['*.html', 'blog/**/*.html'],
      blog: 'blog'
    },
    watch: watchConfig,
    sdedit: {
      sequence: {
        expand: true,
        cwd: 'src',
        src: ['**/*.sd'],
        dest: 'images',
        extDot: 'last',
        ext: '.png'
      }
    },

    connect: {
      server: {
        options: {
          open: true,
          livereload: true,
          host: 'localhost',
          hostname: 'localhost'
        }
      }
    },

    pug: {
      compile: {
        options: {
          data: require('./src/fillViewModel.js'),
          filters: { // Add markdown-it-named-headers as plugin
            'markdown-it': function (text, options) {
              return md.render(text, {
                plugins: ['markdown-it-named-headers'],
                html: true
              }).body;
            }

          }
        },
        pretty: true,

        cwd: 'src',
        src: ['**/*.pug', '!layout/*.pug'],
        dest: './',
        ext: '.html',
        expand: true
      }
    },

    'npm-contributors': {
      options: {
        commitMessage: 'chore: update contributors'
      }
    }
  };

  grunt.initConfig(config);
  grunt.registerTask('serve', ['clean', 'pug', 'connect', 'watch']);
  grunt.registerTask('build', ['clean', 'pug', 'npm-contributors']);
};<commit_msg>Fix gruntfile task for sass<commit_after>var md = require('jstransformer')(require('jstransformer-markdown-it'));
const sdedit = require('./tasks/grunt-sdedit');
const sass = require('./tasks/grunt-sass');

module.exports = function (grunt) {

  const sdFiles = grunt.file.expand('src/**/*.sd');

  grunt.loadNpmTasks('grunt-contrib-pug');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-npm');
  sdedit(grunt);
  sass(grunt);

  const watchConfig = {
    options: {
      livereload: true
    },
    sdedit: {
      files: ['src/**/*.sd'],
      tasks: ['sdedit']
    },
    sass: {
      files: ['src/**/*.scss'],
      tasks: ['sass']
    },
    pug: {
      files: ['src/**/*.pug', 'src/**/*.js', 'src/**/*.json'],
      tasks: ['pug']
    },
    js: {
      files: ['javascripts/**/*.js']
    },
    css: {
      files: ['stylesheets/**/*.css']
    }
  };

  const config = {
    clean: {
      html: ['*.html', 'blog/**/*.html'],
      blog: 'blog'
    },
    watch: watchConfig,
    sdedit: {
      sequence: {
        expand: true,
        cwd: 'src',
        src: ['**/*.sd'],
        dest: 'images',
        extDot: 'last',
        ext: '.png'
      }
    },

    connect: {
      server: {
        options: {
          open: true,
          livereload: true,
          host: 'localhost',
          hostname: 'localhost'
        }
      }
    },

    sass: {
      bootstrap: {
        src: ['src/scss/custom.scss'],
        dest: 'css/bootstrap.css'
      }
    },

    pug: {
      compile: {
        options: {
          data: require('./src/fillViewModel.js'),
          filters: { // Add markdown-it-named-headers as plugin
            'markdown-it': function (text, options) {
              return md.render(text, {
                plugins: ['markdown-it-named-headers'],
                html: true
              }).body;
            }

          }
        },
        pretty: true,

        cwd: 'src',
        src: ['**/*.pug', '!layout/*.pug'],
        dest: './',
        ext: '.html',
        expand: true
      }
    },

    'npm-contributors': {
      options: {
        commitMessage: 'chore: update contributors'
      }
    }
  };

  grunt.initConfig(config);
  grunt.registerTask('serve', ['clean', 'sass', 'pug', 'connect', 'watch']);
  grunt.registerTask('build', ['clean', 'sass', 'pug', 'npm-contributors']);
};
<|endoftext|>