<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        basedir: require("path").resolve("."),
        test_app_uri: "http://localhost/webino/<%= pkg.name %>/._test/ZendSkeletonApplication/public/",
        clean: {
            log: {
                src: ["._log"]
            },
            api: {
                src: ["._api"]
            },
            test_app_vendor: {
                src: ["._test/ZendSkeletonApplication/vendor"]
            },
            test_app_cfg: {
                src: ["._test/ZendSkeletonApplication/config/application.config.php"]
            }
        },
        mkdir: {
            log: {
                options: {
                    create: [
                        "._log",
                        "._log/api",
                        "._log/code-browser",
                        "._log/coverage"
                    ]
                }
            }
        },
        exec: {
            classmap: {
                cmd: "php vendor/bin/classmap_generator.php -l src/<%= pkg.name %>"
            },
            didef: {
                cmd: "php bin/definition_generator.php"
            },
            phploc: {
                cmd: "vendor/bin/phploc --log-csv ._log/phploc.csv src"
            },
            pdepend: {
                cmd: "vendor/bin/pdepend --summary-xml=._log/pdepend.xml --jdepend-xml=._log/jdepend.xml --jdepend-chart=._log/dependencies.svg --overview-pyramid=._log/overview-pyramid.svg src"
            },
            phpcb: {
                cmd: "vendor/bin/phpcb --log ._log --source src --output ._log/code-browser"
            },
            phpdoc: {
                cmd: "vendor/bin/phpdoc.php"
            },
            selenium_start: {
                cmd: "sudo /etc/init.d/selenium start && sleep 5s"
            },
            selenium_test: {
                cmd: "URI='" + (grunt.option('uri') || "<%= test_app_uri %>") + "' vendor/bin/phpunit -c test/selenium"
            },
            selenium_stop: {
                cmd: "sudo /etc/init.d/selenium stop"
            },
            link_precommit: {
                cmd: "ln -s <%= basedir %>/pre-commit <%= basedir %>/.git/hooks/pre-commit && chmod +x <%= basedir %>/pre-commit"
            },
            add_classmap: {
                cmd: "git add src/<%= pkg.name %>/autoload_classmap.php"
            },
            add_didef: {
                cmd: "git add data/di"
            },
            get_composer: {
                cmd: "curl -sS https://getcomposer.org/installer | php"
            },
            composer_self_update: {
                cmd: "php composer.phar self-update"
            },
            composer_update_dev: {
                cmd: "php composer.phar update --dev --no-interaction"
            },
            get_test_app: {
                cmd: "git clone git://github.com/zendframework/ZendSkeletonApplication.git ._test/ZendSkeletonApplication"
            },
            test_app_reset: {
                cmd: "cd ._test/ZendSkeletonApplication && git reset HEAD --hard"
            },
            test_app_clean: {
                cmd: "cd ._test/ZendSkeletonApplication && git clean -fdx"
            },
            test_app_pull: {
                cmd: "cd ._test/ZendSkeletonApplication && git pull origin master"
            },
            test_app_link_vendor: {
                cmd: "ln -s <%= basedir %>/vendor <%= basedir %>/._test/ZendSkeletonApplication/vendor"
            },
            test_app_link_cfg: {
                cmd: "ln -s <%= basedir %>/test/resources/config/application.config.php <%= basedir %>/._test/ZendSkeletonApplication/config/application.config.php"
            }
        },
        phplint: {
            src: ["src/**/*.php"],
            test: ["test/**/*.php"],
            config: ["config/**/*.php"]
        },
        phpunit: {
            options: {
                configuration: "test",
                bin: "vendor/bin/phpunit",
                coverageHtml: "<%= basedir %>/._log/coverage",
                testdoxHtml: "<%= basedir %>/._log/testdox.html",
                coverageClover: "<%= basedir %>/._log/clover.html",
                logJunit: "<%= basedir %>/._log/junit.xml",
                colors: true
            },
            package: {dir: ""}
        },
        phpcs: {
            options: {
                standard: "PSR2",
                extensions: "php",
                bin: "vendor/bin/phpcs",
                report: "checkstyle",
                reportFile: "._log/checkstyle.html",
                verbose: true
            },
            package: {dir: ["src", "test"]}
        },
        phpmd: {
            options: {
                bin: "vendor/bin/phpmd",
                rulesets: "codesize,design,naming,unusedcode",
                reportFile: "._log/phpmd.xml"
            },
            package: {dir: "src/<%= pkg.name %>"}
        },
        phpcpd: {
            options: {
                bin: "vendor/bin/phpcpd",
                reportFile: "._log/pmd-cpd.xml"
            },
            package: {dir: "src"}
        },
        todos: {
            options: {
                priorities : {
                    low : null,
                    med : /(TODO|todo)/,
                    high : /(FIXME|fixme)/
                },
                reporter: {
                    header: function (options) {
                        grunt.file.write("._log/todos.txt", "");
                        return "-- Begin Task List --\n";
                    },
                    fileTasks: function (file, tasks, options) {
                        if (!tasks.length) {
                            return "";
                        }
                        var result = "";
                        result += "For " + file + "\n";
                        tasks.forEach(function (task) {
                            result += "[" + task.lineNumber + " - " + task.priority + "] " + task.line + "\n";
                        });
                        result += "\n";
                        grunt.file.write("._log/todos.txt", grunt.file.read("._log/todos.txt") + result);
                        return result;
                    },
                    footer: function () {
                        return "-- End Task List--\n";
                    }
                },
                verbose: false
            },
            package: {
                src: ["src/**/*.php"]
            }
        }
    });
    //
    grunt.registerTask(
        "build",
        "Build the package",
        [
            "update",
            "test",
            "selenium_test",
            "analyze",
            "api"
        ]
    );
    grunt.registerTask(
        "update",
        "Update the package development environment",
        [
            "precommit:init",
            "composer:init",
            "test_app:init",
            "clean:test_app_vendor",
            "exec:test_app_link_vendor",
            "exec:composer_update_dev",
            "clean:test_app_cfg",
            "exec:test_app_link_cfg"
        ]
    );
    grunt.registerTask(
        "test",
        "Run PHPUnit tests",
        [
            "clean:log",
            "mkdir:log",
            "phplint",
            "phpunit",
            "phpcs"
        ]
    );
    grunt.registerTask(
        "selenium_test",
        "Run Selenium tests",
        [
            "exec:selenium_start",
            "exec:selenium_test",
            "exec:selenium_stop"
        ]
    );
    grunt.registerTask(
        "analyze",
        "Analyze the code",
        [
            "phpmd",
            "exec:phploc",
            "exec:pdepend",
            "exec:phpcb",
            "todos"
        ]
    );
    grunt.registerTask(
        "api",
        "Generate API",
        [
            "clean:api",
            "exec:phpdoc"
        ]
    );
    grunt.registerTask(
        "precommit:init",
        "Initialize git pre-commit",
        function() {
            if (grunt.file.isLink(".git/hooks/pre-commit")) {
                grunt.log.ok("Git pre-commit hook OK ...");
                return;
            }
            grunt.log.ok("Installing git pre-commit hook ...");
            grunt.task.run("exec:link_precommit");
        }
    );
    grunt.registerTask(
        "precommit",
        "Git pre-commit",
        [
            "exec:classmap",
            "test",
            "exec:didef",
            "exec:add_classmap",
            "exec:add_didef"
        ]
    );
    grunt.registerTask(
        "composer:init",
        "Initialize PHP composer",
        function() {
            if (grunt.file.isFile("composer.phar")) {
                grunt.log.ok("Updating composer.phar ...");
                grunt.task.run("exec:composer_self_update");
                return;
            }
            grunt.log.ok("Downloading composer.phar ...");
            grunt.task.run("exec:get_composer");
        }
    );
    grunt.registerTask(
        "test_app:init",
        "Initialize test application",
        function() {
            if (grunt.file.isDir("._test/ZendSkeletonApplication")) {
                grunt.log.ok("Updating test application ...");
                grunt.task.run(["exec:test_app_reset", "exec:test_app_clean", "exec:test_app_pull"]);
                return;
            }
            grunt.log.ok("Downloading test application ...");
            grunt.task.run("exec:get_test_app");
        }
    );
    //
    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-mkdir");
    grunt.loadNpmTasks("grunt-phplint");
    grunt.loadNpmTasks("grunt-phpunit");
    grunt.loadNpmTasks("grunt-phpcs");
    grunt.loadNpmTasks("grunt-phpmd");
    grunt.loadNpmTasks("grunt-phpcpd");
    grunt.loadNpmTasks("grunt-todos");
};
<commit_msg>Fixed Gruntfile.js, removed mkdir log api<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        basedir: require("path").resolve("."),
        test_app_uri: "http://localhost/webino/<%= pkg.name %>/._test/ZendSkeletonApplication/public/",
        clean: {
            log: {
                src: ["._log"]
            },
            api: {
                src: ["._api"]
            },
            test_app_vendor: {
                src: ["._test/ZendSkeletonApplication/vendor"]
            },
            test_app_cfg: {
                src: ["._test/ZendSkeletonApplication/config/application.config.php"]
            }
        },
        mkdir: {
            log: {
                options: {
                    create: [
                        "._log",
                        "._log/code-browser",
                        "._log/coverage"
                    ]
                }
            }
        },
        exec: {
            classmap: {
                cmd: "php vendor/bin/classmap_generator.php -l src/<%= pkg.name %>"
            },
            didef: {
                cmd: "php bin/definition_generator.php"
            },
            phploc: {
                cmd: "vendor/bin/phploc --log-csv ._log/phploc.csv src"
            },
            pdepend: {
                cmd: "vendor/bin/pdepend --summary-xml=._log/pdepend.xml --jdepend-xml=._log/jdepend.xml --jdepend-chart=._log/dependencies.svg --overview-pyramid=._log/overview-pyramid.svg src"
            },
            phpcb: {
                cmd: "vendor/bin/phpcb --log ._log --source src --output ._log/code-browser"
            },
            phpdoc: {
                cmd: "vendor/bin/phpdoc.php"
            },
            selenium_start: {
                cmd: "sudo /etc/init.d/selenium start && sleep 5s"
            },
            selenium_test: {
                cmd: "URI='" + (grunt.option('uri') || "<%= test_app_uri %>") + "' vendor/bin/phpunit -c test/selenium"
            },
            selenium_stop: {
                cmd: "sudo /etc/init.d/selenium stop"
            },
            link_precommit: {
                cmd: "ln -s <%= basedir %>/pre-commit <%= basedir %>/.git/hooks/pre-commit && chmod +x <%= basedir %>/pre-commit"
            },
            add_classmap: {
                cmd: "git add src/<%= pkg.name %>/autoload_classmap.php"
            },
            add_didef: {
                cmd: "git add data/di"
            },
            get_composer: {
                cmd: "curl -sS https://getcomposer.org/installer | php"
            },
            composer_self_update: {
                cmd: "php composer.phar self-update"
            },
            composer_update_dev: {
                cmd: "php composer.phar update --dev --no-interaction"
            },
            get_test_app: {
                cmd: "git clone git://github.com/zendframework/ZendSkeletonApplication.git ._test/ZendSkeletonApplication"
            },
            test_app_reset: {
                cmd: "cd ._test/ZendSkeletonApplication && git reset HEAD --hard"
            },
            test_app_clean: {
                cmd: "cd ._test/ZendSkeletonApplication && git clean -fdx"
            },
            test_app_pull: {
                cmd: "cd ._test/ZendSkeletonApplication && git pull origin master"
            },
            test_app_link_vendor: {
                cmd: "ln -s <%= basedir %>/vendor <%= basedir %>/._test/ZendSkeletonApplication/vendor"
            },
            test_app_link_cfg: {
                cmd: "ln -s <%= basedir %>/test/resources/config/application.config.php <%= basedir %>/._test/ZendSkeletonApplication/config/application.config.php"
            }
        },
        phplint: {
            src: ["src/**/*.php"],
            test: ["test/**/*.php"],
            config: ["config/**/*.php"]
        },
        phpunit: {
            options: {
                configuration: "test",
                bin: "vendor/bin/phpunit",
                coverageHtml: "<%= basedir %>/._log/coverage",
                testdoxHtml: "<%= basedir %>/._log/testdox.html",
                coverageClover: "<%= basedir %>/._log/clover.html",
                logJunit: "<%= basedir %>/._log/junit.xml",
                colors: true
            },
            package: {dir: ""}
        },
        phpcs: {
            options: {
                standard: "PSR2",
                extensions: "php",
                bin: "vendor/bin/phpcs",
                report: "checkstyle",
                reportFile: "._log/checkstyle.html",
                verbose: true
            },
            package: {dir: ["src", "test"]}
        },
        phpmd: {
            options: {
                bin: "vendor/bin/phpmd",
                rulesets: "codesize,design,naming,unusedcode",
                reportFile: "._log/phpmd.xml"
            },
            package: {dir: "src/<%= pkg.name %>"}
        },
        phpcpd: {
            options: {
                bin: "vendor/bin/phpcpd",
                reportFile: "._log/pmd-cpd.xml"
            },
            package: {dir: "src"}
        },
        todos: {
            options: {
                priorities : {
                    low : null,
                    med : /(TODO|todo)/,
                    high : /(FIXME|fixme)/
                },
                reporter: {
                    header: function (options) {
                        grunt.file.write("._log/todos.txt", "");
                        return "-- Begin Task List --\n";
                    },
                    fileTasks: function (file, tasks, options) {
                        if (!tasks.length) {
                            return "";
                        }
                        var result = "";
                        result += "For " + file + "\n";
                        tasks.forEach(function (task) {
                            result += "[" + task.lineNumber + " - " + task.priority + "] " + task.line + "\n";
                        });
                        result += "\n";
                        grunt.file.write("._log/todos.txt", grunt.file.read("._log/todos.txt") + result);
                        return result;
                    },
                    footer: function () {
                        return "-- End Task List--\n";
                    }
                },
                verbose: false
            },
            package: {
                src: ["src/**/*.php"]
            }
        }
    });
    //
    grunt.registerTask(
        "build",
        "Build the package",
        [
            "update",
            "test",
            "selenium_test",
            "analyze",
            "api"
        ]
    );
    grunt.registerTask(
        "update",
        "Update the package development environment",
        [
            "precommit:init",
            "composer:init",
            "test_app:init",
            "clean:test_app_vendor",
            "exec:test_app_link_vendor",
            "exec:composer_update_dev",
            "clean:test_app_cfg",
            "exec:test_app_link_cfg"
        ]
    );
    grunt.registerTask(
        "test",
        "Run PHPUnit tests",
        [
            "clean:log",
            "mkdir:log",
            "phplint",
            "phpunit",
            "phpcs"
        ]
    );
    grunt.registerTask(
        "selenium_test",
        "Run Selenium tests",
        [
            "exec:selenium_start",
            "exec:selenium_test",
            "exec:selenium_stop"
        ]
    );
    grunt.registerTask(
        "analyze",
        "Analyze the code",
        [
            "phpmd",
            "exec:phploc",
            "exec:pdepend",
            "exec:phpcb",
            "todos"
        ]
    );
    grunt.registerTask(
        "api",
        "Generate API",
        [
            "clean:api",
            "exec:phpdoc"
        ]
    );
    grunt.registerTask(
        "precommit:init",
        "Initialize git pre-commit",
        function() {
            if (grunt.file.isLink(".git/hooks/pre-commit")) {
                grunt.log.ok("Git pre-commit hook OK ...");
                return;
            }
            grunt.log.ok("Installing git pre-commit hook ...");
            grunt.task.run("exec:link_precommit");
        }
    );
    grunt.registerTask(
        "precommit",
        "Git pre-commit",
        [
            "exec:classmap",
            "test",
            "exec:didef",
            "exec:add_classmap",
            "exec:add_didef"
        ]
    );
    grunt.registerTask(
        "composer:init",
        "Initialize PHP composer",
        function() {
            if (grunt.file.isFile("composer.phar")) {
                grunt.log.ok("Updating composer.phar ...");
                grunt.task.run("exec:composer_self_update");
                return;
            }
            grunt.log.ok("Downloading composer.phar ...");
            grunt.task.run("exec:get_composer");
        }
    );
    grunt.registerTask(
        "test_app:init",
        "Initialize test application",
        function() {
            if (grunt.file.isDir("._test/ZendSkeletonApplication")) {
                grunt.log.ok("Updating test application ...");
                grunt.task.run(["exec:test_app_reset", "exec:test_app_clean", "exec:test_app_pull"]);
                return;
            }
            grunt.log.ok("Downloading test application ...");
            grunt.task.run("exec:get_test_app");
        }
    );
    //
    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-mkdir");
    grunt.loadNpmTasks("grunt-phplint");
    grunt.loadNpmTasks("grunt-phpunit");
    grunt.loadNpmTasks("grunt-phpcs");
    grunt.loadNpmTasks("grunt-phpmd");
    grunt.loadNpmTasks("grunt-phpcpd");
    grunt.loadNpmTasks("grunt-todos");
};
<|endoftext|>


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

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

    simplemocha: {
      options: {
        timeout: 3000,
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'dot'
      },

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

    watch: {
      files: [
        'Gruntfile.js',
        'app/**/*',
        'admin/**/*',
        'shared/**/*',
        'server/**/*',
        'vendor/**/*',
        '!vendor/**/*.min.*',
        'test/**/*'
      ],
      tasks: ['default']
    },

    sass: {
      options: {includePaths: ['.']},
      app: {src: 'app/css/app.scss', dest: 'tmp/linksf.css'},
      admin: {src: 'admin/css/admin.scss', dest: 'tmp/linksf_admin.css'}
    },

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

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

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

      admin: {
        src: 'admin/js/admin.js',
        dest: 'tmp/admin.js',
        options: {
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'admin/js/lib',          src: '*.js',  dest: 'lib' },
            { cwd: 'admin/js/models',       src: '*.js',  dest: 'models' },
            { cwd: 'admin/js/collections',  src: '*.js',  dest: 'collections' },
            { cwd: 'admin/js/routers',      src: '*.js',  dest: 'routers' },
            { cwd: 'admin/js/templates',    src: '*.hbs', dest: 'templates' },
            { cwd: 'admin/js/views',        src: '*.js',  dest: 'views' }
          ]
        }
      }
    },

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

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

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

      app: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/backbone_filters.js',
          'vendor/js/jquery.switch.js',
          'vendor/js/bootstrap-button.js',
          'vendor/js/fastclick.js',
          'tmp/app.js'
        ],
        dest: 'tmp/linksf.js'
      },

      app_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/backbone_filters.min.js',
          'vendor/js/jquery.switch.min.js',
          'vendor/js/bootstrap-button.min.js',
          'vendor/js/fastclick.min.js',
          'tmp/app.min.js'
        ],
        dest: 'tmp/linksf.js'
      },

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

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

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

      vendor: {
        files: {
          'vendor/js/jquery.serialize-object.min.js': 'vendor/js/jquery.serialize-object.js',
          'vendor/js/backbone_filters.min.js': 'vendor/js/backbone_filters.js',
          'vendor/js/bootstrap-button.min.js': 'vendor/js/bootstrap-button.js'
        }
      },
      app: {files: {'tmp/app.min.js': 'tmp/app.js'}},
      admin: {files: {'tmp/admin.min.js': 'tmp/admin.js'}}
    },

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

    cachebuster: {
      all: {
        files: {src: ['tmp/*.js', 'tmp/*.css']},
        options: {
          complete: function(hashes) {
            var keyMap = {
              'tmp/linksf.js':        'appJs',
              'tmp/linksf.css':       'appCss',
              'tmp/linksf_admin.js':  'adminJs',
              'tmp/linksf_admin.css': 'adminCss'
            };

            var context = {
              parseAppId: process.env.PARSE_APP_ID,
              parseJsKey: process.env.PARSE_JS_KEY,
              gaToken:    process.env.GOOGLE_ANALYTICS_TOKEN,
              gaHost:     process.env.GOOGLE_ANALYTICS_HOST
            };

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

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

            grunt.file.write('index.html',
              grunt.template.process(grunt.file.read('app/index.html'), {data: context})
            );

            grunt.file.write('admin.html',
              grunt.template.process(grunt.file.read('admin/admin.html'), {data: context})
            );

            grunt.file.write('test/acceptance/app.html',
              grunt.template.process(grunt.file.read('test/acceptance/app.template'), {data: context})
            );
          }
        }
      }
    },

    qunit: {all: ['test/acceptance/**/*.html']},

    env: {
      dev: {src: '.env.dev'},
      prod: {src: '.env.prod'}
    },

    autoprefixer: {
      options: {
        browsers: [
          'android >= 2.3',
          'last 3 versions'
        ]
      },
      all: {
        src: 'tmp/*.css'
      }
    },

    aws: grunt.file.readJSON('s3.json'),
    aws_s3: {
      options: {
        accessKeyId: '<%= aws.AWS_ACCESS_KEY_ID %>',
        secretAccessKey: '<%= aws.AWS_SECRET_ACCESS_KEY %>',
      },
      dev: {
        options: {
          debug: true,
          bucket: '<%= aws.AWS_DEV_BUCKET %>'
        },
        files: [
          {expand: true, src: 'build/linksf**'},
          {expand: true, src: 'index.html'},
          {expand: true, src: 'admin.html'},
          {expand: true, src: 'vendor/font/**'},
          {expand: true, src: 'img/**'}
        ]
      },
      prod: {
        options: {
          debug: true,
          bucket: '<%= aws.AWS_PROD_BUCKET %>'
        },
        files: [
          {expand: true, src: 'build/linksf**'},
          {expand: true, src: 'index.html'},
          {expand: true, src: 'admin.html'},
          {expand: true, src: 'vendor/font/**'},
          {expand: true, src: 'img/**'}
        ]
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-cachebuster');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-env');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-aws-s3');
  grunt.loadTasks('tasks');

  grunt.registerTask('build:prereqs', [
    'clean',
    'jshint',
    'simplemocha',
    'tokens'
  ]);

  grunt.registerTask('build:dev', [
    'env:dev',
    'build:prereqs',
    'sass',
    'browserify',
    'concat:app',
    'concat:admin',
    'autoprefixer',
    'cachebuster',
    'qunit'
  ]);

  grunt.registerTask('build:production', [
    'env:prod',
    'build:prereqs',
    'sass',
    'cssmin',
    'browserify',
    'uglify',
    'concat:app_min',
    'concat:admin_min',
    'autoprefixer',
    'cachebuster',
    'qunit'
  ]);

  grunt.registerTask('default', 'build:dev');

  grunt.registerTask('deploy:dev', [
    'build:dev',
    'aws_s3:dev'
  ]);

  grunt.registerTask('deploy:prod', [
    'build:prod',
    'aws_s3:prod'
  ]);
};
<commit_msg>configurable s3 region, add concurrent uploads during deploy<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

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

    simplemocha: {
      options: {
        timeout: 3000,
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'dot'
      },

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

    watch: {
      files: [
        'Gruntfile.js',
        'app/**/*',
        'admin/**/*',
        'shared/**/*',
        'server/**/*',
        'vendor/**/*',
        '!vendor/**/*.min.*',
        'test/**/*'
      ],
      tasks: ['default']
    },

    sass: {
      options: {includePaths: ['.']},
      app: {src: 'app/css/app.scss', dest: 'tmp/linksf.css'},
      admin: {src: 'admin/css/admin.scss', dest: 'tmp/linksf_admin.css'}
    },

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

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

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

      admin: {
        src: 'admin/js/admin.js',
        dest: 'tmp/admin.js',
        options: {
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'admin/js/lib',          src: '*.js',  dest: 'lib' },
            { cwd: 'admin/js/models',       src: '*.js',  dest: 'models' },
            { cwd: 'admin/js/collections',  src: '*.js',  dest: 'collections' },
            { cwd: 'admin/js/routers',      src: '*.js',  dest: 'routers' },
            { cwd: 'admin/js/templates',    src: '*.hbs', dest: 'templates' },
            { cwd: 'admin/js/views',        src: '*.js',  dest: 'views' }
          ]
        }
      }
    },

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

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

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

      app: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/backbone_filters.js',
          'vendor/js/jquery.switch.js',
          'vendor/js/bootstrap-button.js',
          'vendor/js/fastclick.js',
          'tmp/app.js'
        ],
        dest: 'tmp/linksf.js'
      },

      app_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/backbone_filters.min.js',
          'vendor/js/jquery.switch.min.js',
          'vendor/js/bootstrap-button.min.js',
          'vendor/js/fastclick.min.js',
          'tmp/app.min.js'
        ],
        dest: 'tmp/linksf.js'
      },

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

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

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

      vendor: {
        files: {
          'vendor/js/jquery.serialize-object.min.js': 'vendor/js/jquery.serialize-object.js',
          'vendor/js/backbone_filters.min.js': 'vendor/js/backbone_filters.js',
          'vendor/js/bootstrap-button.min.js': 'vendor/js/bootstrap-button.js'
        }
      },
      app: {files: {'tmp/app.min.js': 'tmp/app.js'}},
      admin: {files: {'tmp/admin.min.js': 'tmp/admin.js'}}
    },

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

    cachebuster: {
      all: {
        files: {src: ['tmp/*.js', 'tmp/*.css']},
        options: {
          complete: function(hashes) {
            var keyMap = {
              'tmp/linksf.js':        'appJs',
              'tmp/linksf.css':       'appCss',
              'tmp/linksf_admin.js':  'adminJs',
              'tmp/linksf_admin.css': 'adminCss'
            };

            var context = {
              parseAppId: process.env.PARSE_APP_ID,
              parseJsKey: process.env.PARSE_JS_KEY,
              gaToken:    process.env.GOOGLE_ANALYTICS_TOKEN,
              gaHost:     process.env.GOOGLE_ANALYTICS_HOST
            };

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

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

            grunt.file.write('index.html',
              grunt.template.process(grunt.file.read('app/index.html'), {data: context})
            );

            grunt.file.write('admin.html',
              grunt.template.process(grunt.file.read('admin/admin.html'), {data: context})
            );

            grunt.file.write('test/acceptance/app.html',
              grunt.template.process(grunt.file.read('test/acceptance/app.template'), {data: context})
            );
          }
        }
      }
    },

    qunit: {all: ['test/acceptance/**/*.html']},

    env: {
      dev: {src: '.env.dev'},
      prod: {src: '.env.prod'}
    },

    autoprefixer: {
      options: {
        browsers: [
          'android >= 2.3',
          'last 3 versions'
        ]
      },
      all: {
        src: 'tmp/*.css'
      }
    },

    aws: grunt.file.readJSON('s3.json'),
    aws_s3: {
      options: {
        accessKeyId: '<%= aws.AWS_ACCESS_KEY_ID %>',
        secretAccessKey: '<%= aws.AWS_SECRET_ACCESS_KEY %>',
        region: '<%= aws.AWS_S3_REGION %>',
        uploadConcurrency: 4
      },
      dev: {
        options: {
          bucket: '<%= aws.AWS_DEV_BUCKET %>'
        },
        files: [
          {expand: true, src: 'build/linksf**'},
          {expand: true, src: 'index.html'},
          {expand: true, src: 'admin.html'},
          {expand: true, src: 'vendor/font/**'},
          {expand: true, src: 'img/**'}
        ]
      },
      prod: {
        options: {
          bucket: '<%= aws.AWS_PROD_BUCKET %>'
        },
        files: [
          {expand: true, src: 'build/linksf**'},
          {expand: true, src: 'index.html'},
          {expand: true, src: 'admin.html'},
          {expand: true, src: 'vendor/font/**'},
          {expand: true, src: 'img/**'}
        ]
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-cachebuster');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-env');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-aws-s3');
  grunt.loadTasks('tasks');

  grunt.registerTask('build:prereqs', [
    'clean',
    'jshint',
    'simplemocha',
    'tokens'
  ]);

  grunt.registerTask('build:dev', [
    'env:dev',
    'build:prereqs',
    'sass',
    'browserify',
    'concat:app',
    'concat:admin',
    'autoprefixer',
    'cachebuster',
    'qunit'
  ]);

  grunt.registerTask('build:production', [
    'env:prod',
    'build:prereqs',
    'sass',
    'cssmin',
    'browserify',
    'uglify',
    'concat:app_min',
    'concat:admin_min',
    'autoprefixer',
    'cachebuster',
    'qunit'
  ]);

  grunt.registerTask('default', 'build:dev');

  grunt.registerTask('deploy:dev', [
    'build:dev',
    'aws_s3:dev'
  ]);

  grunt.registerTask('deploy:prod', [
    'build:prod',
    'aws_s3:prod'
  ]);
};
<|endoftext|>


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

    // All upfront config goes in a massive nested object.
    grunt.initConfig({
        distFolder: 'public/js',

        // Concatenate task
        concat: {
            // Common options for all concatenate task
            options: {
                process: function(src, filepath) {
                    return '// File : ' + filepath + '\n' + src;
                }
            },

            // Concatenate libraries
            lib: {
                src: [
                    'bower_components/jquery/dist/jquery.min.js',
                    'bower_components/jquery-ui/jquery-ui.min.js',
                    'bower_components/bootstrap/dist/js/bootstrap.min.js',
                    'bower_components/angular/angular.min.js',
                    'bower_components/angular-route/angular-route.min.js',
                    'bower_components/angular-ui-sortable/src/sortable.min.js'
                ],
                dest: '<%= distFolder %>/lib.min.js'
            },

            // Concatenate app
            app: {
                // Wrap all application into an anonymous auto-callable function using 'use strict' env ( as recommended for angular app)
                options: {
                    banner: '(function() {\n',
                    footer: '\n})();'
                },
                src: [
                    'app/Administration/module.js',
                    'app/Administration/**/*.js',
                    'app/Dashboard/module.js',
                    'app/Dashboard/**/*.js',
                    'app/Search/module.js',
                    'app/Search/**/*.js',
                    'app/Notification/module.js',
                    'app/Notification/**/*.js',
                    'app/Home/module.js',
                    'app/Home/**/*.js',
                    'app/User/module.js',
                    'app/User/**/*.js',
                    'app/UI/module.js',
                    'app/UI/**/*.js',
                    'app/Task/module.js',
                    'app/Task/**/*.js',
                    'app/Demo/module.js',
                    'app/Demo/**/*.js',

                    'app/**/*.js',
                    'app/app.js'
                ],
                dest: '<%= distFolder %>/app.js'
            }
        },

        // Uglify task
        uglify: {
            // Uglify app
            app: {
                src: [
                    '<%= distFolder %>/app.js'
                ],
                dest: '<%= distFolder %>/app.min.js'
            }
        }
    });

    // Load Grunt task runners
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    // Register our own custom task alias.
    grunt.registerTask('build', ['concat', 'uglify']);
};<commit_msg>add angular ui bootstrap<commit_after>module.exports = function(grunt) {

    // All upfront config goes in a massive nested object.
    grunt.initConfig({
        distFolder: 'public/js',

        // Concatenate task
        concat: {
            // Common options for all concatenate task
            options: {
                process: function(src, filepath) {
                    return '// File : ' + filepath + '\n' + src;
                }
            },

            // Concatenate libraries
            lib: {
                src: [
                    'bower_components/jquery/dist/jquery.min.js',
                    'bower_components/jquery-ui/jquery-ui.min.js',
                    'bower_components/bootstrap/dist/js/bootstrap.min.js',
                    'bower_components/angular/angular.min.js',
                    'bower_components/angular-route/angular-route.min.js',
                    'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
                    'bower_components/angular-ui-sortable/sortable.min.js'
                ],
                dest: '<%= distFolder %>/lib.min.js'
            },

            // Concatenate app
            app: {
                // Wrap all application into an anonymous auto-callable function using 'use strict' env ( as recommended for angular app)
                options: {
                    banner: '(function() {\n',
                    footer: '\n})();'
                },
                src: [
                    'app/Administration/module.js',
                    'app/Administration/**/*.js',
                    'app/Dashboard/module.js',
                    'app/Dashboard/**/*.js',
                    'app/Search/module.js',
                    'app/Search/**/*.js',
                    'app/Notification/module.js',
                    'app/Notification/**/*.js',
                    'app/Home/module.js',
                    'app/Home/**/*.js',
                    'app/User/module.js',
                    'app/User/**/*.js',
                    'app/UI/module.js',
                    'app/UI/**/*.js',
                    'app/Task/module.js',
                    'app/Task/**/*.js',
                    'app/Demo/module.js',
                    'app/Demo/**/*.js',

                    'app/**/*.js',
                    'app/app.js'
                ],
                dest: '<%= distFolder %>/app.js'
            }
        },

        // Uglify task
        uglify: {
            // Uglify app
            app: {
                src: [
                    '<%= distFolder %>/app.js'
                ],
                dest: '<%= distFolder %>/app.min.js'
            }
        }
    });

    // Load Grunt task runners
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    // Register our own custom task alias.
    grunt.registerTask('build', ['concat', 'uglify']);
};<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('bower.json'),
    app: {
      name: 'Tock.js',
      version: '<%= pkg.version %>',
      license: '<%= pkg.license %>',
      homepage: '<%= pkg.homepage %>',
      files: {
        gruntfile: ['Gruntfile.js'],
        js: ['tock.js']
      },
      targets: {
        gruntfile: [{
          src: '<%= app.files.gruntfile %>'
        }],
        main: [{
          expand: true,
          src: '<%= app.files.js %>',
          ext: '.min.js',
          extDot: 'last'
        }]
      }
    },
    jshint: {
      options: {
        'camelcase': true,
        'curly': true,
        'eqeqeq': true,
        'newcap': true,
        'undef': true,
        'unused': true
      },
      gruntfile: {
        files: '<%= app.targets.gruntfile %>',
        options: {
          'predef': [
            'module'
          ]
        }
      },
      main: {
        files: '<%= app.targets.main %>',
        options: {
          'browser': true,
          'devel': true,
          'predef': [
            'define',
            'module',
            'require'
          ]
        }
      }
    },
    jscs: {
      options: {
        'disallowSpacesInNamedFunctionExpression': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpacesInFunctionExpression': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpacesInAnonymousFunctionExpression': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpacesInFunctionDeclaration': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpaceBeforeBinaryOperators': [
          ','
        ],
        'requireSpaceBeforeBinaryOperators': true,
        'requireSpaceAfterBinaryOperators': true,
        'requireCamelCaseOrUpperCaseIdentifiers': true,
        'requireCapitalizedConstructors': true,
        'disallowMixedSpacesAndTabs': true,
        'disallowTrailingWhitespace': true,
        'disallowTrailingComma': true,
        'disallowSpaceAfterPrefixUnaryOperators': true,
        'disallowSpaceBeforePostfixUnaryOperators': true,
        'disallowSpacesInsideArrayBrackets': true,
        'disallowSpacesInsideParentheses': true,
        'requireSpaceAfterKeywords': [
          'if',
          'else',
          'for',
          'while',
          'do',
          'switch',
          'case',
          'return',
          'try',
          'catch',
          'typeof'
        ],
        'validateIndentation': 2,
        'validateLineBreaks': 'LF',
        'validateQuoteMarks': true
      },
      gruntfile: {
        files: '<%= app.targets.gruntfile %>'
      },
      main: {
        files: '<%= app.targets.main %>'
      }
    },
    uglify: {
      options: {
        banner: '// <%= app.name %> (version <%= app.version %>) <%= app.homepage %>\n// License: <%= app.license %>\n',
        compress: {
          comparisons: false
        }
      },
      main: {
        files: '<%= app.targets.main %>'
      }
    },
    watch: {
      gruntfile: {
        files: '<%= app.files.gruntfile %>',
        tasks: ['check:gruntfile', 'build']
      },
      main: {
        files: '<%= app.files.js %>',
        tasks: ['build:main']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-jscs');

  grunt.registerTask('check:gruntfile', ['jshint:gruntfile', 'jscs:gruntfile']);
  grunt.registerTask('check:main', ['jshint:main', 'jscs:main']);
  grunt.registerTask('check', ['check:gruntfile', 'check:main']);

  grunt.registerTask('build:main', ['check:main', 'uglify:main']);
  grunt.registerTask('build', ['build:main']);

  grunt.registerTask('default', ['check:gruntfile', 'build']);
};
<commit_msg>Update Gruntfile.js<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('bower.json'),
    app: {
      name:     'Tock.js',
      version:  '<%= pkg.version %>',
      license:  '<%= pkg.license %>',
      homepage: '<%= pkg.homepage %>',
      paths: {
        src:  'src',
        dist: 'dist'
      },
      files: {
        gruntfile: ['Gruntfile.js'],
        js:        ['tock.js']
      }
    },
    jshint: {
      options: {
        camelcase:  true,
        curly:      true,
        eqeqeq:     true,
        jquery:     true,
        newcap:     true,
        undef:      true,
        unused:     true,
        validthis:  true
      },
      gruntfile: {
        options: {
          predef: [
            'module'
          ]
        },
        src: '<%= app.files.gruntfile %>'
      },
      js: {
        options: {
          browser: true,
          devel:   true,
          predef:  [
            'define',
            'module',
            'require'
          ]
        },
        src: '<%= app.paths.src %>/<%= app.files.js %>'
      }
    },
    jscs: {
      options: {
        'disallowSpacesInNamedFunctionExpression': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpacesInFunctionExpression': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpacesInAnonymousFunctionExpression': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpacesInFunctionDeclaration': {
          'beforeOpeningRoundBrace': true
        },
        'disallowSpaceBeforeBinaryOperators': [
          ','
        ],
        'requireSpaceBeforeBinaryOperators': true,
        'requireSpaceAfterBinaryOperators': true,
        'requireCamelCaseOrUpperCaseIdentifiers': true,
        'requireCapitalizedConstructors': true,
        'disallowMixedSpacesAndTabs': true,
        'disallowTrailingWhitespace': true,
        'disallowTrailingComma': true,
        'disallowSpaceAfterPrefixUnaryOperators': true,
        'disallowSpaceBeforePostfixUnaryOperators': true,
        'disallowSpacesInsideArrayBrackets': true,
        'disallowSpacesInsideParentheses': true,
        'requireSpaceAfterKeywords': [
          'if',
          'else',
          'for',
          'while',
          'do',
          'switch',
          'case',
          'return',
          'try',
          'catch',
          'typeof'
        ],
        'validateIndentation': 2,
        'validateLineBreaks': 'LF',
        'validateQuoteMarks': true
      },
      gruntfile: {
        options: {
          'requireCamelCaseOrUpperCaseIdentifiers': 'ignoreProperties'
        },
        src: '<%= app.files.gruntfile %>'
      },
      js: {
        src: '<%= app.paths.src %>/<%= app.files.js %>'
      }
    },
    umd: {
      js: {
        src:            '<%= app.paths.src %>/<%= app.files.js %>',
        dest:           '<%= app.paths.dist %>/<%= app.files.js %>',
        amdModuleId:    '<%= pkg.name %>',  // AMD
        objectToExport: '<%= app.name %>',  // CommonJS
        globalAlias:    '<%= app.name %>',  // Global
        deps:           {}
      }
    },
    uglify: {
      options: {
        banner: '// <%= app.name %> (version <%= app.version %>) <%= app.homepage %>\n// License: <%= app.license %>\n',
        compress: {
          comparisons: false
        }
      },
      js: {
        files: [{
          src:    '<%= umd.js.dest %>',
          ext:    '.min.js',
          expand: true
        }]
      }
    },
    watch: {
      gruntfile: {
        files: '<%= app.files.gruntfile %>',
        tasks: ['check:gruntfile', 'build']
      },
      js: {
        options: {
          cwd: '<%= app.paths.src %>'
        },
        files: '<%= app.files.js %>',
        tasks: ['build:js']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-jscs');
  grunt.loadNpmTasks('grunt-notify');
  grunt.loadNpmTasks('grunt-umd');

  grunt.registerTask('check:gruntfile', ['jshint:gruntfile', 'jscs:gruntfile']);
  grunt.registerTask('check:js', ['jshint:js', 'jscs:js']);
  grunt.registerTask('check', ['check:gruntfile', 'check:js']);

  grunt.registerTask('build:js', ['check:js', 'umd:js', 'uglify:js']);
  grunt.registerTask('build', ['build:js']);

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


<commit_before>"use strict";
var webpackConfig = require("./webpack.config");

module.exports = function (grunt) {
    var pkg = grunt.file.readJSON("package.json");
    grunt.initConfig({
        pkgName: pkg.name,
        name: pkg.name,

        watch: {
            updateWidgetFiles: {
                "files": [ "./dist/tmp/src/**/*" ],
                "tasks": [ "compress:dist", "copy:distDeployment", "copy:mpk" ],
                options: {
                    debounceDelay: 250,
                    livereload: true
                }
            },
            sourceFiles: {
                "files": [ "./src/**/*" ],
                "tasks": [ "copy:source" ]
            }
        },

        compress: {
            dist: {
                options: {
                    archive: "./dist/" + pkg.version + "/" + pkg.name + ".mpk",
                    mode: "zip"
                },
                files: [ {
                    expand: true,
                    date: new Date(),
                    store: false,
                    cwd: "./dist/tmp/src",
                    src: [ "**/*" ]
                } ]
            }
        },

        copy: {
            distDeployment: {
                files: [ {
                    dest: "./dist/MxTestProject/deployment/web/widgets",
                    cwd: "./dist/tmp/src/",
                    src: [ "**/*" ],
                    expand: true
                } ]
            },
            mpk: {
                files: [ {
                    dest: "./dist/MxTestProject/widgets",
                    cwd: "./dist/" + pkg.version + "/",
                    src: [ pkg.name + ".mpk" ],
                    expand: true
                } ]
            },
            source: {
                files: [
                    {
                        dest: "./dist/tmp/src",
                        cwd: "./src/",
                        src: [ "**/*", "!**/*.ts", "!**/*.css" ],
                        expand: true
                    }
                ]
            }
        },

        webpack: {
            renderer: webpackConfig
        },

        clean: {
            build: [
                "./dist/" + pkg.version + "/" + pkg.name + "/*",
                "./dist/tmp/**/*",
                "./dist/MxTestProject/deployment/web/widgets/" + pkg.name + "/*",
                "./dist/MxTestProject/widgets/" + pkg.name + ".mpk"
            ]
        },

        checkDependencies: {
            this: {},
        }
    });

    grunt.loadNpmTasks("grunt-contrib-compress");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-check-dependencies");
    grunt.loadNpmTasks("grunt-webpack");

    grunt.registerTask("default", [ "clean build", "watch" ]);
    grunt.registerTask(
        "clean build",
        "Compiles all the assets and copies the files to the build directory.",
        [ "checkDependencies", "clean:build", "webpack", "compress:dist", "copy:mpk" ]
    );
    grunt.registerTask("build", [ "clean build" ]);
};
<commit_msg>Fix live reload, add webpack to grunt watch<commit_after>"use strict";
var webpackConfig = require("./webpack.config");

module.exports = function (grunt) {
    var pkg = grunt.file.readJSON("package.json");
    grunt.initConfig({
        pkgName: pkg.name,
        name: pkg.name,

        watch: {
            updateWidgetFiles: {
                "files": [ "./dist/tmp/src/**/*" ],
                "tasks": [  "webpack", "compress:dist", "copy:distDeployment", "copy:mpk" ],
                options: {
                    debounceDelay: 250,
                    livereload: true
                }
            },
            sourceFiles: {
                "files": [ "./src/**/*" ],
                "tasks": [ "copy:source" ]
            }
        },

        compress: {
            dist: {
                options: {
                    archive: "./dist/" + pkg.version + "/" + pkg.name + ".mpk",
                    mode: "zip"
                },
                files: [ {
                    expand: true,
                    date: new Date(),
                    store: false,
                    cwd: "./dist/tmp/src",
                    src: [ "**/*" ]
                } ]
            }
        },

        copy: {
            distDeployment: {
                files: [ {
                    dest: "./dist/MxTestProject/deployment/web/widgets",
                    cwd: "./dist/tmp/src/",
                    src: [ "**/*" ],
                    expand: true
                } ]
            },
            mpk: {
                files: [ {
                    dest: "./dist/MxTestProject/widgets",
                    cwd: "./dist/" + pkg.version + "/",
                    src: [ pkg.name + ".mpk" ],
                    expand: true
                } ]
            },
            source: {
                files: [
                    {
                        dest: "./dist/tmp/src",
                        cwd: "./src/",
                        src: [ "**/*", "!**/*.ts", "!**/*.css" ],
                        expand: true
                    }
                ]
            }
        },

        webpack: {
            renderer: webpackConfig
        },

        clean: {
            build: [
                "./dist/" + pkg.version + "/" + pkg.name + "/*",
                "./dist/tmp/**/*",
                "./dist/MxTestProject/deployment/web/widgets/" + pkg.name + "/*",
                "./dist/MxTestProject/widgets/" + pkg.name + ".mpk"
            ]
        },

        checkDependencies: {
            this: {},
        }
    });

    grunt.loadNpmTasks("grunt-contrib-compress");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-check-dependencies");
    grunt.loadNpmTasks("grunt-webpack");

    grunt.registerTask("default", [ "clean build", "watch" ]);
    grunt.registerTask(
        "clean build",
        "Compiles all the assets and copies the files to the build directory.",
        [ "checkDependencies", "clean:build", "webpack", "compress:dist", "copy:mpk" ]
    );
    grunt.registerTask("build", [ "clean build" ]);
};
<|endoftext|>


<commit_before>/*
 * grunt-tv4
 * https://github.com/Bartvds/grunt-tv4
 *
 * Copyright (c) 2013 Bart van der Schoor
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {
	/*jshint unused:false*/

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

	var util = require('util');

	//used by format checker
	var dateRegex = /^\d{4}-\d{1,2}-\d{1,2}$/;
	var dateValidateCallback = function (data, schema) {
		if (typeof data !== 'string' || !dateRegex.test(data)) {
			// return error message
			return 'value must be string of the form: YYYY-MM-DD';
		}
		return null;
	};

	grunt.initConfig({
		jshint: {
			options: grunt.util._.defaults(grunt.file.readJSON('.jshintrc'), {
				reporter: './node_modules/jshint-path-reporter'
			}),
			all: [
				'Gruntfile.js',
				'lib/**/*.js',
				'tasks/**/*.js'
			]
		}
	});

	grunt.registerTask('test', ['jshint']);
	grunt.registerTask('default', ['test']);
};
<commit_msg>Add release-it grunt task<commit_after>/*
 * grunt-tv4
 * https://github.com/Bartvds/grunt-tv4
 *
 * Copyright (c) 2013 Bart van der Schoor
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {
	/*jshint unused:false*/

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

	var util = require('util');

	//used by format checker
	var dateRegex = /^\d{4}-\d{1,2}-\d{1,2}$/;
	var dateValidateCallback = function (data, schema) {
		if (typeof data !== 'string' || !dateRegex.test(data)) {
			// return error message
			return 'value must be string of the form: YYYY-MM-DD';
		}
		return null;
	};

	grunt.initConfig({
		jshint: {
			options: grunt.util._.defaults(grunt.file.readJSON('.jshintrc'), {
				reporter: './node_modules/jshint-path-reporter'
			}),
			all: [
				'Gruntfile.js',
				'lib/**/*.js',
				'tasks/**/*.js'
			]
		},
		'release-it': {
			options: {
				pkgFiles: ['package.json'],
				commitMessage: 'Release %s',
				tagName: '%s',
				tagAnnotation: 'Release %s',
				buildCommand: false
			}
		}
	});

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


<commit_before>//require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

module.exports = function(grunt) {
  // Do grunt-related things in here

	// Project configuration.
	grunt.initConfig({
		concurrent: {
			dev: {
				tasks: ['nodemon', 'watch'], //'node-inspector', 'watch'], <-- node-inspector, a debugger, don't need yet
				options: {
					logConcurrentOutput: true
				}
			}
		},
		eslint: {
			target: [
				'Gruntfile.js',
				'biz/*.js',
				'confit/*.js',
				'model/*.js',
				'routes/*.js',
				'tests/**/*.js'
			]
		},
		'node-inspector': {
			custom: {
				options: {
					// 'web-port' : 1667
				}
			}
		},
		nodemon: {
			dev: {
				script: './app.js',//'./bin/www',//'index.js',
				options: {
					ignore: ['node_modules/**']//,
				}
			}
		},
		pkg: grunt.file.readJSON('package.json'),
		babel: {
			options: {
				sourceMap: true,
				presets: ['es2015']
			},
			files: {
				expand: true,
				src: ['**/*.es6'],
				ext: '-compiled.js'
			},
			dist: {
				files: {
					'dist/app.js': 'app.js'
				}
			}
		}
//	  uglify: {
//	    options: {
//	      banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
//	    },
//	    build: {
//	      src: 'src/<%= pkg.name %>.js',
//	      dest: 'build/<%= pkg.name %>.min.js'
//	    }
//	  }
	});

	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-nodemon');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-babel');
	grunt.loadNpmTasks('grunt-eslint');
	grunt.loadNpmTasks('grunt-node-inspector');

	// Default task(s).
	grunt.registerTask('lint', ['eslint']);
	grunt.registerTask('default', ['babel', 'nodemon']);
	grunt.registerTask('basic', ['nodemon']);

};<commit_msg>Add mochaTest task to Gruntfile<commit_after>//require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

module.exports = function(grunt) {
  // Do grunt-related things in here

	// Project configuration.
	grunt.initConfig({
		concurrent: {
			dev: {
				tasks: ['nodemon', 'watch'], //'node-inspector', 'watch'], <-- node-inspector, a debugger, don't need yet
				options: {
					logConcurrentOutput: true
				}
			}
		},
		eslint: {
			target: [
				'Gruntfile.js',
				'biz/*.js',
				'confit/*.js',
				'model/*.js',
				'routes/*.js',
				'tests/**/*.js'
			]
		},
        mochaTest: {
            test: {
                src: ['test/unittests/*.js']
            }
        },
		'node-inspector': {
			custom: {
				options: {
					// 'web-port' : 1667
				}
			}
		},
		nodemon: {
			dev: {
				script: './app.js',//'./bin/www',//'index.js',
				options: {
					ignore: ['node_modules/**']//,
				}
			}
		},
		pkg: grunt.file.readJSON('package.json'),
		babel: {
			options: {
				sourceMap: true,
				presets: ['es2015']
			},
			files: {
				expand: true,
				src: ['**/*.es6'],
				ext: '-compiled.js'
			},
			dist: {
				files: {
					'dist/app.js': 'app.js'
				}
			}
		}
//	  uglify: {
//	    options: {
//	      banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
//	    },
//	    build: {
//	      src: 'src/<%= pkg.name %>.js',
//	      dest: 'build/<%= pkg.name %>.min.js'
//	    }
//	  }
	});

	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-nodemon');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-babel');
	grunt.loadNpmTasks('grunt-eslint');
	grunt.loadNpmTasks('grunt-node-inspector');
    grunt.loadNpmTasks('grunt-mocha-test');

	// Default task(s).
	grunt.registerTask('lint', ['eslint']);
	grunt.registerTask('default', ['babel', 'nodemon']);
	grunt.registerTask('basic', ['nodemon']);

};
<|endoftext|>


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

    var version = grunt.option('release'),
        zipName = (version) ? version : 'DEV';

    // Project configuration.
    grunt.initConfig({
        connect: {
            dev: {
                options: {
                    port: 8580,
                    base: '.',
                    keepalive: true
                }
            },
            test: {
                options: {
                    port: 8581,
                    base: '.'
                }
            },
            prod: {
                options: {
                    port: process.env.PORT || 8585,
                    base: './dist/',
                    keepalive: true,
                    middleware: function(connect, options) {
                        // Return array of whatever middlewares you want
                        return [

                            function(req, res, next) {
                                res.setHeader('Content-Security-Policy', "default-src 'self'; object-src 'none'; connect-src 'self' https://keys.whiteout.io; img-src 'self' data:;");

                                return next();
                            },

                            // Serve static files.
                            connect.static(options.base)
                        ];
                    }
                }
            }
        },

        jshint: {
            all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        mocha: {
            all: {
                options: {
                    urls: [
                        'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
                        'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
                    ],
                    run: false,
                    reporter: 'Spec',
                    log: false,

                    // phanotmjs is soooo slow
                    timeout: 100000
                }
            }
        },

        clean: {
            dist: ['dist', 'src/lib/*.js', 'test/lib', 'test/integration/src']
        },
        sass: {
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/sass/read-sandbox.scss',
                    'src/css/all.css': 'src/sass/all.scss'
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 versions']
            },
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/css/read-sandbox.css',
                    'src/css/all.css': 'src/css/all.css'
                }
            }
        },
        csso: {
            options: {
                banner: '/*! Copyright © 2013, Whiteout Networks GmbH. All rights reserved.*/\n'
            },
            dist: {
                files: {
                    'dist/css/read-sandbox.min.css': 'src/css/read-sandbox.css',
                    'dist/css/all.min.css': 'src/css/all.css'
                }
            }
        },
        watch: {
            css: {
                files: ['src/sass/**/*.scss'],
                tasks: ['dist-css']
            },
            js: {
                files: ['src/js/**/*.js'],
                tasks: ['copy:js']
            },
            lib: {
                files: ['src/lib/**/*.js'],
                tasks: ['copy:lib']
            },
            app: {
                files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/img/**/*', 'src/font/**/*'],
                tasks: ['copy:app', 'copy:ca', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev']
            }
        },
        copy: {
            npm: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: [
                    'requirejs/require.js',
                    'imap-client/src/*.js',
                    'imap-client/node_modules/browserbox/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/imap-handler/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/mimefuncs/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/tcp-socket/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/utf7/src/*.js',
                    'mailreader/src/*.js',
                    'mailreader/node_modules/mimeparser/src/*.js',
                    'mailreader/node_modules/mimeparser/node_modules/addressparser/src/*.js',
                    'pgpbuilder/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/mimetypes/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/punycode/punycode.min.js',
                    'pgpmailer/src/*.js',
                    'pgpmailer/node_modules/smtpclient/src/*.js',
                    'pgpmailer/node_modules/smtpclient/node_modules/stringencoding/dist/stringencoding.js',
                    'axe/axe.js',
                    'dompurify/purify.js',
                    'jquery/dist/jquery.min.js',
                    'ng-infinite-scroll/build/ng-infinite-scroll.min.js'
                ],
                dest: 'src/lib/'
            },
            npmDev: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'angularjs/src/ngMock/angular-mocks.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'],
                dest: 'test/lib/'
            },
            cryptoLib: {
                expand: true,
                cwd: 'node_modules/crypto-lib/src/',
                src: ['*.js'],
                dest: 'src/js/crypto/'
            },
            lib: {
                expand: true,
                cwd: 'src/lib/',
                src: ['**'],
                dest: 'dist/lib/'
            },
            js: {
                expand: true,
                cwd: 'src/js/',
                src: ['**'],
                dest: 'dist/js/'
            },
            font: {
                expand: true,
                cwd: 'src/font/',
                src: ['*'],
                dest: 'dist/font/'
            },
            img: {
                expand: true,
                cwd: 'src/img/',
                src: ['*'],
                dest: 'dist/img/'
            },
            tpl: {
                expand: true,
                cwd: 'src/tpl/',
                src: ['*'],
                dest: 'dist/tpl/'
            },
            ca: {
                expand: true,
                cwd: 'src/ca/',
                src: ['*'],
                dest: 'dist/ca/'
            },
            app: {
                expand: true,
                cwd: 'src/',
                src: ['*.html', '*.js', '*.json'],
                dest: 'dist/'
            },
            integration: {
                expand: true,
                cwd: 'src/',
                src: ['**'],
                dest: 'test/integration/src/'
            }
        },

        compress: {
            main: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.zip'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: 'release/'
            },
            nodeWebkit: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.nw'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: '/'
            }
        },

        nodewebkit: {
            options: {
                version: '0.9.2', // node-webkit version
                build_dir: './release/node-webkit/', // Where the build version of my node-webkit app is saved
                mac: true, // We want to build it for mac
                win: false, // We want to build it for win
                linux32: false, // We don't need linux32
                linux64: false, // We don't need linux64
            },
            src: ['./dist/**/*'] // Your node-webkit app
        },
    });

    // Load the plugin(s)
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-csso');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.loadNpmTasks('grunt-node-webkit-builder');

    // Build tasks
    grunt.registerTask('dist-npm', ['copy:npm', 'copy:npmDev', 'copy:cryptoLib']);
    grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
    grunt.registerTask('dist-copy', ['copy']);
    grunt.registerTask('dist', ['clean', 'dist-npm', 'dist-css', 'dist-copy']);

    // Test/Dev tasks
    grunt.registerTask('dev', ['connect:dev']);
    grunt.registerTask('test', ['jshint', 'connect:test', 'mocha']);
    grunt.registerTask('prod', ['connect:prod']);

    //
    // Release tasks for Chrome App Release Channels
    //

    grunt.registerTask('manifest-dev', function() {
        patchManifest({
            suffix: ' (DEV)',
            version: '9999.9999.9999.9999'
        });
    });
    grunt.registerTask('manifest-test', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            suffix: ' (TEST)',
            client_id: '440907777130-bfpgo5fbo4f7hetrg3hn57qolrtubs0u.apps.googleusercontent.com',
            version: version,
            deleteKey: true
        });
    });
    grunt.registerTask('manifest-stable', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            suffix: ' (Beta)',
            version: version,
            deleteKey: true,
            keyServer: 'https://keys.whiteout.io/',
            keychainServer: 'https://keychain.whiteout.io/'
        });
    });

    function patchManifest(options) {
        var fs = require('fs'),
            path = './dist/manifest.json',
            manifest = require(path);

        if (options.version) {
            manifest.version = options.version;
        }
        if (options.suffix) {
            manifest.name += options.suffix;
        }
        if (options.client_id) {
            manifest.oauth2.client_id = options.client_id;
        }
        if (options.keyServer) {
            var ksIndex = manifest.permissions.indexOf('https://keys-test.whiteout.io/');
            manifest.permissions[ksIndex] = options.keyServer;
        }
        if (options.keychainServer) {
            var kcsIndex = manifest.permissions.indexOf('https://keychain-test.whiteout.io/');
            manifest.permissions[kcsIndex] = options.keychainServer;
        }
        if (options.deleteKey) {
            delete manifest.key;
        }

        fs.writeFileSync(path, JSON.stringify(manifest, null, 2));
    }

    grunt.registerTask('release-dev', ['dist', 'manifest-dev', 'compress']);
    grunt.registerTask('release-test', ['dist', 'manifest-test', 'compress']);
    grunt.registerTask('release-stable', ['dist', 'manifest-stable', 'compress']);
    grunt.registerTask('default', ['release-dev']);

};<commit_msg>Remove (Beta) suffix from manifest name for Android<commit_after>module.exports = function(grunt) {
    'use strict';

    var version = grunt.option('release'),
        zipName = (version) ? version : 'DEV';

    // Project configuration.
    grunt.initConfig({
        connect: {
            dev: {
                options: {
                    port: 8580,
                    base: '.',
                    keepalive: true
                }
            },
            test: {
                options: {
                    port: 8581,
                    base: '.'
                }
            },
            prod: {
                options: {
                    port: process.env.PORT || 8585,
                    base: './dist/',
                    keepalive: true,
                    middleware: function(connect, options) {
                        // Return array of whatever middlewares you want
                        return [

                            function(req, res, next) {
                                res.setHeader('Content-Security-Policy', "default-src 'self'; object-src 'none'; connect-src 'self' https://keys.whiteout.io; img-src 'self' data:;");

                                return next();
                            },

                            // Serve static files.
                            connect.static(options.base)
                        ];
                    }
                }
            }
        },

        jshint: {
            all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        mocha: {
            all: {
                options: {
                    urls: [
                        'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
                        'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
                    ],
                    run: false,
                    reporter: 'Spec',
                    log: false,

                    // phanotmjs is soooo slow
                    timeout: 100000
                }
            }
        },

        clean: {
            dist: ['dist', 'src/lib/*.js', 'test/lib', 'test/integration/src']
        },
        sass: {
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/sass/read-sandbox.scss',
                    'src/css/all.css': 'src/sass/all.scss'
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 versions']
            },
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/css/read-sandbox.css',
                    'src/css/all.css': 'src/css/all.css'
                }
            }
        },
        csso: {
            options: {
                banner: '/*! Copyright © 2013, Whiteout Networks GmbH. All rights reserved.*/\n'
            },
            dist: {
                files: {
                    'dist/css/read-sandbox.min.css': 'src/css/read-sandbox.css',
                    'dist/css/all.min.css': 'src/css/all.css'
                }
            }
        },
        watch: {
            css: {
                files: ['src/sass/**/*.scss'],
                tasks: ['dist-css']
            },
            js: {
                files: ['src/js/**/*.js'],
                tasks: ['copy:js']
            },
            lib: {
                files: ['src/lib/**/*.js'],
                tasks: ['copy:lib']
            },
            app: {
                files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/img/**/*', 'src/font/**/*'],
                tasks: ['copy:app', 'copy:ca', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev']
            }
        },
        copy: {
            npm: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: [
                    'requirejs/require.js',
                    'imap-client/src/*.js',
                    'imap-client/node_modules/browserbox/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/imap-handler/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/mimefuncs/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/tcp-socket/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/utf7/src/*.js',
                    'mailreader/src/*.js',
                    'mailreader/node_modules/mimeparser/src/*.js',
                    'mailreader/node_modules/mimeparser/node_modules/addressparser/src/*.js',
                    'pgpbuilder/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/mimetypes/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/punycode/punycode.min.js',
                    'pgpmailer/src/*.js',
                    'pgpmailer/node_modules/smtpclient/src/*.js',
                    'pgpmailer/node_modules/smtpclient/node_modules/stringencoding/dist/stringencoding.js',
                    'axe/axe.js',
                    'dompurify/purify.js',
                    'jquery/dist/jquery.min.js',
                    'ng-infinite-scroll/build/ng-infinite-scroll.min.js'
                ],
                dest: 'src/lib/'
            },
            npmDev: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'angularjs/src/ngMock/angular-mocks.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'],
                dest: 'test/lib/'
            },
            cryptoLib: {
                expand: true,
                cwd: 'node_modules/crypto-lib/src/',
                src: ['*.js'],
                dest: 'src/js/crypto/'
            },
            lib: {
                expand: true,
                cwd: 'src/lib/',
                src: ['**'],
                dest: 'dist/lib/'
            },
            js: {
                expand: true,
                cwd: 'src/js/',
                src: ['**'],
                dest: 'dist/js/'
            },
            font: {
                expand: true,
                cwd: 'src/font/',
                src: ['*'],
                dest: 'dist/font/'
            },
            img: {
                expand: true,
                cwd: 'src/img/',
                src: ['*'],
                dest: 'dist/img/'
            },
            tpl: {
                expand: true,
                cwd: 'src/tpl/',
                src: ['*'],
                dest: 'dist/tpl/'
            },
            ca: {
                expand: true,
                cwd: 'src/ca/',
                src: ['*'],
                dest: 'dist/ca/'
            },
            app: {
                expand: true,
                cwd: 'src/',
                src: ['*.html', '*.js', '*.json'],
                dest: 'dist/'
            },
            integration: {
                expand: true,
                cwd: 'src/',
                src: ['**'],
                dest: 'test/integration/src/'
            }
        },

        compress: {
            main: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.zip'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: 'release/'
            },
            nodeWebkit: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.nw'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: '/'
            }
        },

        nodewebkit: {
            options: {
                version: '0.9.2', // node-webkit version
                build_dir: './release/node-webkit/', // Where the build version of my node-webkit app is saved
                mac: true, // We want to build it for mac
                win: false, // We want to build it for win
                linux32: false, // We don't need linux32
                linux64: false, // We don't need linux64
            },
            src: ['./dist/**/*'] // Your node-webkit app
        },
    });

    // Load the plugin(s)
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-csso');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.loadNpmTasks('grunt-node-webkit-builder');

    // Build tasks
    grunt.registerTask('dist-npm', ['copy:npm', 'copy:npmDev', 'copy:cryptoLib']);
    grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
    grunt.registerTask('dist-copy', ['copy']);
    grunt.registerTask('dist', ['clean', 'dist-npm', 'dist-css', 'dist-copy']);

    // Test/Dev tasks
    grunt.registerTask('dev', ['connect:dev']);
    grunt.registerTask('test', ['jshint', 'connect:test', 'mocha']);
    grunt.registerTask('prod', ['connect:prod']);

    //
    // Release tasks for Chrome App Release Channels
    //

    grunt.registerTask('manifest-dev', function() {
        patchManifest({
            suffix: ' (DEV)',
            version: '9999.9999.9999.9999'
        });
    });
    grunt.registerTask('manifest-test', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            suffix: ' (TEST)',
            client_id: '440907777130-bfpgo5fbo4f7hetrg3hn57qolrtubs0u.apps.googleusercontent.com',
            version: version,
            deleteKey: true
        });
    });
    grunt.registerTask('manifest-stable', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            version: version,
            deleteKey: true,
            keyServer: 'https://keys.whiteout.io/',
            keychainServer: 'https://keychain.whiteout.io/'
        });
    });

    function patchManifest(options) {
        var fs = require('fs'),
            path = './dist/manifest.json',
            manifest = require(path);

        if (options.version) {
            manifest.version = options.version;
        }
        if (options.suffix) {
            manifest.name += options.suffix;
        }
        if (options.client_id) {
            manifest.oauth2.client_id = options.client_id;
        }
        if (options.keyServer) {
            var ksIndex = manifest.permissions.indexOf('https://keys-test.whiteout.io/');
            manifest.permissions[ksIndex] = options.keyServer;
        }
        if (options.keychainServer) {
            var kcsIndex = manifest.permissions.indexOf('https://keychain-test.whiteout.io/');
            manifest.permissions[kcsIndex] = options.keychainServer;
        }
        if (options.deleteKey) {
            delete manifest.key;
        }

        fs.writeFileSync(path, JSON.stringify(manifest, null, 2));
    }

    grunt.registerTask('release-dev', ['dist', 'manifest-dev', 'compress']);
    grunt.registerTask('release-test', ['dist', 'manifest-test', 'compress']);
    grunt.registerTask('release-stable', ['dist', 'manifest-stable', 'compress']);
    grunt.registerTask('default', ['release-dev']);

};<|endoftext|>