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

        /**
         * Project Paths Configuration
         * ===============================
         */
        paths: {
            images: 'img',
            dist: 'dist',
            src: 'app',
            email: 'index.html',
            txt: 'index.txt',
            distDomain: '',
            devDomain: '',
        		sender: {
          		service: '',
          		user: '',
              pass: ''
        		},
        		recipients: {
          		name: '',
          		email: ''
        		}
        },

        /**
         * SCSS Compilation Tasks
         * ===============================
         */
        compass: {
            options: {
                sassDir: '<%= paths.src %>/scss',
                outputStyle: 'expanded',
                httpImagesPath: '/img/'
            },
            dev: {
                options: {
                    cssDir: '<%= paths.src %>/css',
                    imagesDir: '<%= paths.src %>/<%= paths.images %>',
                    noLineComments: false
                }
            },
            dist: {
                options: {
                    force: true,
                    cssDir: '<%= paths.dist %>/css',
                    imagesDir: '<%= paths.dist %>/<%= paths.images %>',
                    noLineComments: true,
                    assetCacheBuster: false,
                    outputStyle: "compact"
                }
            }
        },

        /**
         * Watch Task
         * ===============================
         */
        watch: {
            compass: {
                files: ['<%= paths.src %>/scss/**/*.scss'],
                tasks: ['compass:dev']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= paths.src %>/<%= paths.email %>',
                    '<%= paths.src %>/css/{,*/}*.css',
                    '<%= paths.src %>/<%= paths.images %>/{,*/}*.{png,jpg,jpeg,gif}'
                ]
            }
        },

        /**
         * Server Tasks
         * ===============================
         */
        connect: {
            options: {
                open: true,
                hostname: 'localhost',
                port: 8000,
                livereload: 35729
            },
            dev: {
                options: {
                    base: '<%= paths.src %>',
                    index: '<%= paths.email %>'
                }
            },
            dist: {
                options: {
                    keepalive: true,
                    livereload: false,
                    base: '<%= paths.dist %>'
                }
            }
        },

        /**
         * Cleanup Tasks
         * ===============================
         */
        clean: {
            dist: ['<%= paths.dist %>']
        },

        /**
         * Images Optimization Tasks
         * ===============================
         */
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.src %>/<%= paths.images %>',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= paths.dist %>/<%= paths.images %>'
                }]
            }
        },

        /**
         * Premailer Parser Tasks
         * ===============================
         */
        premailer: {
            options: {
                baseUrl: '<%= paths.distDomain %>'
            },
            plain: {
                options: {
                    mode: 'txt'
                },
                src: '<%= paths.src %>/<%= paths.email %>',
                dest: '<%= paths.dist %>/<%= paths.txt %>'
            },
            dist: {
                src: '<%= paths.src %>/<%= paths.email %>',
                dest: '<%= paths.dist %>/<%= paths.email %>'
            }
        },

         /**
         * Replacement Tasks
         * ===============================
         */
        replace: {
          imageDir: {
            src: '<%= paths.dist %>/index.html',
            dest: '<%= paths.dist %>/index.html',
            replacements: [{
              from: '/img/',
              to: '/'
            }]
          }
        },

        /**
         * Test Mailer Tasks
         * ===============================
         */
        nodemailer: {
            options: {
                transport: {
                    type: 'SMTP',
                    options: {
                        service: '<%= paths.sender.service  %>',
                        auth: {
                            user: '<%= paths.sender.user  %>',
                            pass: '<%= paths.sender.pass  %>'
                        }
                    }
                },
                recipients: [
              		{
                		name: '<%= paths.recipients.name  %>',
                		email: '<%= paths.recipients.email %>'
              		}
            		]
            },
            dist: {
                src: ['<%= paths.dist %>/<%= paths.email %>']
            }
        },

        prompt: {
            target: {
                options: {
                    questions: [{
                        config: 'paths.recipients.name',
                        type: 'input',
                        message: 'Who should we send this to (name)?',
                        default: '<%= paths.recipients.name  %>'
                    },
                    {
                        config: 'paths.recipients.email',
                        type: 'input',
                        message: 'Who should we send this to (email)?',
                        default: '<%= paths.recipients.email  %>'
                    }]
                }
            }
        }

    });

    [
        'grunt-contrib-connect',
        'grunt-contrib-watch',
        'grunt-contrib-compass',
        'grunt-contrib-imagemin',
        'grunt-contrib-clean',
        'grunt-text-replace',
        'grunt-premailer',
        'grunt-prompt',
        'grunt-nodemailer',
    ].forEach(grunt.loadNpmTasks);

    grunt.registerTask('default', 'serve');

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

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

      grunt.task.run([
        'compass:dev',
        'connect:dev',
        'watch'
      ]);
    });

    grunt.registerTask('build', [
        'clean',
        'imagemin',
        'compass:dist',
        'premailer:dist',
        'premailer:plain',
        'replace'
    ]);

    grunt.registerTask('send', [
        'build',
        'prompt:target',
        'nodemailer'
    ]);

};
<commit_msg>added subject to the test email<commit_after>module.exports = function (grunt) {
    'use strict';
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        /**
         * Project Paths Configuration
         * ===============================
         */
        paths: {
            images: 'img',
            dist: 'dist',
            src: 'app',
            email: 'index.html',
            txt: 'index.txt',
            distDomain: '',
        		sender: {
          		service: '',
          		user: '',
              pass: ''
        		},
        		recipients: {
          		name: '',
          		email: '',
          		subject: ''
        		}
        },

        /**
         * SCSS Compilation Tasks
         * ===============================
         */
        compass: {
            options: {
                sassDir: '<%= paths.src %>/scss',
                outputStyle: 'expanded',
                httpImagesPath: '/img/'
            },
            dev: {
                options: {
                    cssDir: '<%= paths.src %>/css',
                    imagesDir: '<%= paths.src %>/<%= paths.images %>',
                    noLineComments: false
                }
            },
            dist: {
                options: {
                    force: true,
                    cssDir: '<%= paths.dist %>/css',
                    imagesDir: '<%= paths.dist %>/<%= paths.images %>',
                    noLineComments: true,
                    assetCacheBuster: false,
                    outputStyle: "compact"
                }
            }
        },

        /**
         * Watch Task
         * ===============================
         */
        watch: {
            compass: {
                files: ['<%= paths.src %>/scss/**/*.scss'],
                tasks: ['compass:dev']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= paths.src %>/<%= paths.email %>',
                    '<%= paths.src %>/css/{,*/}*.css',
                    '<%= paths.src %>/<%= paths.images %>/{,*/}*.{png,jpg,jpeg,gif}'
                ]
            }
        },

        /**
         * Server Tasks
         * ===============================
         */
        connect: {
            options: {
                open: true,
                hostname: 'localhost',
                port: 8000,
                livereload: 35729
            },
            dev: {
                options: {
                    base: '<%= paths.src %>',
                    index: '<%= paths.email %>'
                }
            },
            dist: {
                options: {
                    keepalive: true,
                    livereload: false,
                    base: '<%= paths.dist %>'
                }
            }
        },

        /**
         * Cleanup Tasks
         * ===============================
         */
        clean: {
            dist: ['<%= paths.dist %>']
        },

        /**
         * Images Optimization Tasks
         * ===============================
         */
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.src %>/<%= paths.images %>',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= paths.dist %>/<%= paths.images %>'
                }]
            }
        },

        /**
         * Premailer Parser Tasks
         * ===============================
         */
        premailer: {
            options: {
                baseUrl: '<%= paths.distDomain %>'
            },
            plain: {
                options: {
                    mode: 'txt'
                },
                src: '<%= paths.src %>/<%= paths.email %>',
                dest: '<%= paths.dist %>/<%= paths.txt %>'
            },
            dist: {
                src: '<%= paths.src %>/<%= paths.email %>',
                dest: '<%= paths.dist %>/<%= paths.email %>'
            }
        },

         /**
         * Replacement Tasks
         * ===============================
         */
        replace: {
          imageDir: {
            src: '<%= paths.dist %>/index.html',
            dest: '<%= paths.dist %>/index.html',
            replacements: [{
              from: '/img/',
              to: '/'
            }]
          }
        },

        /**
         * Test Mailer Tasks
         * ===============================
         */
        nodemailer: {
            options: {
                transport: {
                    type: 'SMTP',
                    options: {
                        service: '<%= paths.sender.service  %>',
                        auth: {
                            user: '<%= paths.sender.user  %>',
                            pass: '<%= paths.sender.pass  %>'
                        }
                    }
                },
                message: {
                  subject: '<%= paths.recipients.subject  %>'
                },
                recipients: [
              		{
                		name: '<%= paths.recipients.name  %>',
                		email: '<%= paths.recipients.email %>'
              		}
            		]
            },
            dist: {
                src: ['<%= paths.dist %>/<%= paths.email %>']
            }
        },

        prompt: {
            target: {
                options: {
                    questions: [{
                        config: 'paths.recipients.name',
                        type: 'input',
                        message: 'Who should we send this to (name)?',
                        default: '<%= paths.recipients.name  %>'
                    },
                    {
                        config: 'paths.recipients.email',
                        type: 'input',
                        message: 'Who should we send this to (email)?',
                        default: '<%= paths.recipients.email  %>'
                    },
                    {
                        config: 'paths.recipients.subject',
                        type: 'input',
                        message: 'What is the subject?',
                        default: '<%= paths.recipients.subject  %>'
                    }]
                }
            }
        }

    });

    [
        'grunt-contrib-connect',
        'grunt-contrib-watch',
        'grunt-contrib-compass',
        'grunt-contrib-imagemin',
        'grunt-contrib-clean',
        'grunt-text-replace',
        'grunt-premailer',
        'grunt-prompt',
        'grunt-nodemailer',
    ].forEach(grunt.loadNpmTasks);

    grunt.registerTask('default', 'serve');

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

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

      grunt.task.run([
        'compass:dev',
        'connect:dev',
        'watch'
      ]);
    });

    grunt.registerTask('build', [
        'clean',
        'imagemin',
        'compass:dist',
        'premailer:dist',
        'premailer:plain',
        'replace'
    ]);

    grunt.registerTask('send', [
        'build',
        'prompt:target',
        'nodemailer'
    ]);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    mochacli: {
      options: {
        require: ['should'],
        files: 'test/*.js',
        save: 'coverage/test-results.xml'
      },
      test: {
        options: {
          reporter: 'XUnit'
        }
      }
    },
    mocha_istanbul: {
      test: {
        src: 'test',
        options: {
          reporter: 'mocha-jenkins-reporter',
          reportFormats: ['cobertura', 'lcov']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-mocha-cli');
  grunt.loadNpmTasks('grunt-mocha-istanbul');

  grunt.registerTask('test', 'run test and generate coverage information', ['mochacli:test','mocha_istanbul:test']);
};<commit_msg>JUnit test<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    mochacli: {
      options: {
        require: ['should'],
        files: 'test/*.js',
        save: 'coverage/test-results.xml'
      },
      test: {
        options: {
          reporter: 'xunit'
        }
      }
    },
    mocha_istanbul: {
      test: {
        src: 'test',
        options: {
          reporter: 'mocha-jenkins-reporter',
          reportFormats: ['cobertura', 'lcov']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-mocha-cli');
  grunt.loadNpmTasks('grunt-mocha-istanbul');

  grunt.registerTask('test', 'run test and generate coverage information', ['mochacli:test','mocha_istanbul:test']);
};<|endoftext|>


<commit_before>/*eslint-env node */

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

  var tsConfig = {
    dev: {
      tsconfig: true
    },
    test: {
      src: ["test/**/*.ts"],
      out: "test/tests.js",
      options: {
        target: "es5",
        sourceMap: false,
        noImplicitAny: true,
        declaration: false,
        removeComments: false
      }
    },
    verifyDefinitionFiles: {
      src: [
        "typings/d3/d3.d.ts",
        "plottable.d.ts",
        "bower_components/svg-typewriter/svgtypewriter.d.ts"
      ],
      options: {
        compiler: "./node_modules/typescript/bin/tsc"
      }
    }
  };

  var bumpConfig = {
    options: {
      files: ["package.json", "bower.json"],
      updateConfigs: ["pkg"],
      commit: false,
      createTag: false,
      push: false,
      prereleaseName: "rc"
    }
  };

  var sedConfig = {
    versionNumber: {
      pattern: "@VERSION",
      replacement: "<%= pkg.version %>",
      path: "plottable.js"
    }
  };

  var umdConfig = {
    all: {
      src: "plottable.js",
      template: "unit",
      objectToExport: "Plottable"
    }
  };

  var concatConfig = {
    header: {
      src: ["license_header.txt", "plottable.js"],
      dest: "plottable.js"
    },
    svgtypewriter: {
      src: ["plottable.js", "bower_components/svg-typewriter/svgtypewriter.js"],
      dest: "plottable.js"
    }
  };

  var tslintConfig = {
    options: {
      configuration: grunt.file.readJSON(".tslintrc")
    },
    all: {
      src: ["src/**/*.ts", "test/**/*.ts"]
    }
  };

  var jscsConfig = {
    files: ["Gruntfile.js", "quicktests/**/*.js"],
    options: {
      config: ".jscsrc"
    }
  };

  var eslintConfig = {
    target: ["Gruntfile.js", "quicktests/**/*.js"],
    options: {
      configFile: ".eslintrc"
    }
  };

  var parallelizeConfig = {
    tslint: {
      all: 4
    }
  };

  var watchConfig = {
    options: {
      livereload: true,
      spawn: false
    },
    rebuild: {
      tasks: ["src-compile"],
      files: ["src/**/*.ts"]
    },
    tests: {
      tasks: ["test-compile"],
      files: ["test/**/*.ts"]
    },
    quicktests: {
      tasks: ["update-quicktests"],
      files: ["quicktests/overlaying/tests/**/*.js"]
    }
  };

  var blanketMochaConfig = {
    all: ["test/coverage.html"],
    options: {
      threshold: 70
    }
  };

  var connectConfig = {
    server: {
      options: {
        port: 9999,
        hostname: "*",
        base: "",
        livereload: true
      }
    }
  };

  var cleanConfig = {
    tscommand: ["tscommand*.tmp.txt"]
  };

  var FILES_TO_COMMIT = [
    "plottable.js",
    "plottable.min.js",
    "plottable.d.ts",
    "plottable.css",
    "plottable.zip",
    "bower.json",
    "package.json"
  ];

  var gitcommitConfig = {
    version: {
      options: {
        message: "Release version <%= pkg.version %>"
      },
      files: {
        src: FILES_TO_COMMIT
      }
    },
    built: {
      options: {
        message: "Update built files"
      },
      files: {
        src: FILES_TO_COMMIT
      }
    }
  };

  var compressConfig = {
    main: {
      options: {
        archive: "plottable.zip"
      },
      files: [
        {src: "plottable.js",     dest: "."},
        {src: "plottable.min.js", dest: "."},
        {src: "plottable.d.ts",   dest: "."},
        {src: "plottable.css",    dest: "."},
        {src: "README.md",        dest: "."},
        {src: "LICENSE",          dest: "."}
      ]
    }
  };

  var uglifyConfig = {
    main: {
      files: {"plottable.min.js": ["plottable.js"]}
    }
  };

  var saucelabsMochaConfig = {
    all: {
      options: {
        urls: ["http://127.0.0.1:9999/test/tests.html"],
        testname: "Plottable Sauce Unit Tests",
        pollInterval: 5000,
        statusCheckAttempts: 60,
        maxRetries: 5,
        browsers: [{
          browserName: "firefox",
          platform: "linux"
        }, {
          browserName: "chrome",
          platform: "linux"
        }, {
          browserName: "internet explorer",
          version: "9",
          platform: "WIN7"
        }, {
          browserName: "iphone",
          platform: "OS X 10.10",
          version: "8.0",
          deviceName: "iPad Simulator",
          deviceOrientation: "portrait"
        }]
      }
    }
  };

  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),
    bump: bumpConfig,
    umd: umdConfig,
    concat: concatConfig,
    ts: tsConfig,
    tslint: tslintConfig,
    jscs: jscsConfig,
    eslint: eslintConfig,
    parallelize: parallelizeConfig,
    watch: watchConfig,
    "blanket_mocha": blanketMochaConfig,
    connect: connectConfig,
    clean: cleanConfig,
    sed: sedConfig,
    gitcommit: gitcommitConfig,
    compress: compressConfig,
    uglify: uglifyConfig,
    "saucelabs-mocha": saucelabsMochaConfig
  });

  // Loads the tasks specified in package.json
  require("load-grunt-tasks")(grunt);

  grunt.registerTask("test-compile", ["ts:test"]);
  grunt.registerTask("src-compile", ["ts:dev", "generateJS"]);

  grunt.registerTask("dev-compile", [
    "src-compile",
    "test-compile",
    "clean:tscommand",
    "update-quicktests"
  ]);

  grunt.registerTask("generateJS", [
    "concat:svgtypewriter",
    "umd:all",
    "concat:header",
    "sed:versionNumber"
  ]);

  grunt.registerTask("release:patch", ["bump:patch", "dist-compile", "gitcommit:version"]);
  grunt.registerTask("release:minor", ["bump:minor", "dist-compile", "gitcommit:version"]);
  grunt.registerTask("release:major", ["bump:major", "dist-compile", "gitcommit:version"]);

  grunt.registerTask("dist-compile", ["test", "uglify", "compress"]);

  grunt.registerTask("commitjs", ["dist-compile", "gitcommit:built"]);
  grunt.registerTask("default", ["connect", "dev-compile", "watch-silent"]);

  grunt.registerTask("test", ["dev-compile", "test-local"]);
  grunt.registerTask("test-local", ["blanket_mocha", "ts:verifyDefinitionFiles", "lint"]);
  grunt.registerTask("test-sauce", ["connect", "saucelabs-mocha"]);

  grunt.registerTask("watch-silent", function() {
    // Surpresses the "Running 'foo' task" messages
    grunt.log.header = function() {};
    grunt.task.run(["watch"]);
  });

  grunt.registerTask("lint", ["parallelize:tslint", "jscs", "eslint"]);

  // Disable saucelabs on dev environments by checking if SAUCE_USERNAME is an environment variable
  if (process.env.SAUCE_USERNAME) {
    grunt.registerTask("test-travis", ["dev-compile", "test-local", "test-sauce"]);
  } else {
    grunt.registerTask("test-travis", ["dev-compile", "test-local"]);
  }

  grunt.registerTask("update-quicktests", function() {
    var qtJSON = [];
    var rawtests = grunt.file.expand("quicktests/overlaying/tests/**/*.js");
    rawtests.forEach(function(value) {
      qtJSON.push({ path: value });
    });
    qtJSON = JSON.stringify(qtJSON);
    qtJSON = qtJSON.split(",").join(",\n") + "\n";
    grunt.file.write("quicktests/overlaying/list_of_quicktests.json", qtJSON);
  });

};
<commit_msg>lower maxRetries to 1<commit_after>/*eslint-env node */

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

  var tsConfig = {
    dev: {
      tsconfig: true
    },
    test: {
      src: ["test/**/*.ts"],
      out: "test/tests.js",
      options: {
        target: "es5",
        sourceMap: false,
        noImplicitAny: true,
        declaration: false,
        removeComments: false
      }
    },
    verifyDefinitionFiles: {
      src: [
        "typings/d3/d3.d.ts",
        "plottable.d.ts",
        "bower_components/svg-typewriter/svgtypewriter.d.ts"
      ],
      options: {
        compiler: "./node_modules/typescript/bin/tsc"
      }
    }
  };

  var bumpConfig = {
    options: {
      files: ["package.json", "bower.json"],
      updateConfigs: ["pkg"],
      commit: false,
      createTag: false,
      push: false,
      prereleaseName: "rc"
    }
  };

  var sedConfig = {
    versionNumber: {
      pattern: "@VERSION",
      replacement: "<%= pkg.version %>",
      path: "plottable.js"
    }
  };

  var umdConfig = {
    all: {
      src: "plottable.js",
      template: "unit",
      objectToExport: "Plottable"
    }
  };

  var concatConfig = {
    header: {
      src: ["license_header.txt", "plottable.js"],
      dest: "plottable.js"
    },
    svgtypewriter: {
      src: ["plottable.js", "bower_components/svg-typewriter/svgtypewriter.js"],
      dest: "plottable.js"
    }
  };

  var tslintConfig = {
    options: {
      configuration: grunt.file.readJSON(".tslintrc")
    },
    all: {
      src: ["src/**/*.ts", "test/**/*.ts"]
    }
  };

  var jscsConfig = {
    files: ["Gruntfile.js", "quicktests/**/*.js"],
    options: {
      config: ".jscsrc"
    }
  };

  var eslintConfig = {
    target: ["Gruntfile.js", "quicktests/**/*.js"],
    options: {
      configFile: ".eslintrc"
    }
  };

  var parallelizeConfig = {
    tslint: {
      all: 4
    }
  };

  var watchConfig = {
    options: {
      livereload: true,
      spawn: false
    },
    rebuild: {
      tasks: ["src-compile"],
      files: ["src/**/*.ts"]
    },
    tests: {
      tasks: ["test-compile"],
      files: ["test/**/*.ts"]
    },
    quicktests: {
      tasks: ["update-quicktests"],
      files: ["quicktests/overlaying/tests/**/*.js"]
    }
  };

  var blanketMochaConfig = {
    all: ["test/coverage.html"],
    options: {
      threshold: 70
    }
  };

  var connectConfig = {
    server: {
      options: {
        port: 9999,
        hostname: "*",
        base: "",
        livereload: true
      }
    }
  };

  var cleanConfig = {
    tscommand: ["tscommand*.tmp.txt"]
  };

  var FILES_TO_COMMIT = [
    "plottable.js",
    "plottable.min.js",
    "plottable.d.ts",
    "plottable.css",
    "plottable.zip",
    "bower.json",
    "package.json"
  ];

  var gitcommitConfig = {
    version: {
      options: {
        message: "Release version <%= pkg.version %>"
      },
      files: {
        src: FILES_TO_COMMIT
      }
    },
    built: {
      options: {
        message: "Update built files"
      },
      files: {
        src: FILES_TO_COMMIT
      }
    }
  };

  var compressConfig = {
    main: {
      options: {
        archive: "plottable.zip"
      },
      files: [
        {src: "plottable.js",     dest: "."},
        {src: "plottable.min.js", dest: "."},
        {src: "plottable.d.ts",   dest: "."},
        {src: "plottable.css",    dest: "."},
        {src: "README.md",        dest: "."},
        {src: "LICENSE",          dest: "."}
      ]
    }
  };

  var uglifyConfig = {
    main: {
      files: {"plottable.min.js": ["plottable.js"]}
    }
  };

  var saucelabsMochaConfig = {
    all: {
      options: {
        urls: ["http://127.0.0.1:9999/test/tests.html"],
        testname: "Plottable Sauce Unit Tests",
        pollInterval: 5000,
        statusCheckAttempts: 60,
        maxRetries: 1,
        browsers: [{
          browserName: "firefox",
          platform: "linux"
        }, {
          browserName: "chrome",
          platform: "linux"
        }, {
          browserName: "internet explorer",
          version: "9",
          platform: "WIN7"
        }, {
          browserName: "iphone",
          platform: "OS X 10.10",
          version: "8.0",
          deviceName: "iPad Simulator",
          deviceOrientation: "portrait"
        }]
      }
    }
  };

  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),
    bump: bumpConfig,
    umd: umdConfig,
    concat: concatConfig,
    ts: tsConfig,
    tslint: tslintConfig,
    jscs: jscsConfig,
    eslint: eslintConfig,
    parallelize: parallelizeConfig,
    watch: watchConfig,
    "blanket_mocha": blanketMochaConfig,
    connect: connectConfig,
    clean: cleanConfig,
    sed: sedConfig,
    gitcommit: gitcommitConfig,
    compress: compressConfig,
    uglify: uglifyConfig,
    "saucelabs-mocha": saucelabsMochaConfig
  });

  // Loads the tasks specified in package.json
  require("load-grunt-tasks")(grunt);

  grunt.registerTask("test-compile", ["ts:test"]);
  grunt.registerTask("src-compile", ["ts:dev", "generateJS"]);

  grunt.registerTask("dev-compile", [
    "src-compile",
    "test-compile",
    "clean:tscommand",
    "update-quicktests"
  ]);

  grunt.registerTask("generateJS", [
    "concat:svgtypewriter",
    "umd:all",
    "concat:header",
    "sed:versionNumber"
  ]);

  grunt.registerTask("release:patch", ["bump:patch", "dist-compile", "gitcommit:version"]);
  grunt.registerTask("release:minor", ["bump:minor", "dist-compile", "gitcommit:version"]);
  grunt.registerTask("release:major", ["bump:major", "dist-compile", "gitcommit:version"]);

  grunt.registerTask("dist-compile", ["test", "uglify", "compress"]);

  grunt.registerTask("commitjs", ["dist-compile", "gitcommit:built"]);
  grunt.registerTask("default", ["connect", "dev-compile", "watch-silent"]);

  grunt.registerTask("test", ["dev-compile", "test-local"]);
  grunt.registerTask("test-local", ["blanket_mocha", "ts:verifyDefinitionFiles", "lint"]);
  grunt.registerTask("test-sauce", ["connect", "saucelabs-mocha"]);

  grunt.registerTask("watch-silent", function() {
    // Surpresses the "Running 'foo' task" messages
    grunt.log.header = function() {};
    grunt.task.run(["watch"]);
  });

  grunt.registerTask("lint", ["parallelize:tslint", "jscs", "eslint"]);

  // Disable saucelabs on dev environments by checking if SAUCE_USERNAME is an environment variable
  if (process.env.SAUCE_USERNAME) {
    grunt.registerTask("test-travis", ["dev-compile", "test-local", "test-sauce"]);
  } else {
    grunt.registerTask("test-travis", ["dev-compile", "test-local"]);
  }

  grunt.registerTask("update-quicktests", function() {
    var qtJSON = [];
    var rawtests = grunt.file.expand("quicktests/overlaying/tests/**/*.js");
    rawtests.forEach(function(value) {
      qtJSON.push({ path: value });
    });
    qtJSON = JSON.stringify(qtJSON);
    qtJSON = qtJSON.split(",").join(",\n") + "\n";
    grunt.file.write("quicktests/overlaying/list_of_quicktests.json", qtJSON);
  });

};
<|endoftext|>


<commit_before>var gruntRequireConfig = require('./src/dev/requireConfig').gruntConfig;
var gruntWrapperRequireConfig = require('./src/dev/requireConfig').gruntWrapperConfig;

module.exports = function (grunt) {
    grunt.initConfig({
        requirejs: {
            core: {
                options: gruntRequireConfig
            },
            wrapper: {
                options: gruntWrapperRequireConfig
            }
        },
        concat: {

        },
        jst: {
            compile: {
                options: {
                    prettify: true,
                    processName: function (filePath) {
                        var parts = filePath.split('/');
                        var fileName = parts[parts.length - 1];
                        return fileName.split('.')[0];
                    },
                    amd: true
                },
                files: {
                    "src/js/generated/templates.js": ["src/templates/*.html"]
                }
            }
        },
        less: {
            development: {
                options: {
                    paths: ['src/less']
                },
                files: {
                    "build/tmp/razorflow.css": "src/less/razorflow.less"
                }
            },
            newdesign: {
                options: {
                    paths: ['src/dev/newdesign/less']
                },
                files: {
                    "src/dev/newdesign/css/razorflow.css":  "src/dev/newdesign/less/razorflow.less"
                }
            },
            theme: {
                files: {
                    "build/tmp/rftheme.default.css": "build/tmp/less/rftheme.default.less"
                }
            }
        },
        jshint: {
            options: {
                jshintrc: 'src/js/.jshintrc'
            },
            files: [
                "src/js/**/*.js"
            ]
        },
        karma: {
            dev: {
                configFile: './karma.conf.js',
                singleRun: true
            }
        },
        lodash: {
            build: {
                dest: 'src/vendor/js/lodash.rf.js',
                options: {
                    include: ['extend', 'pluck', 'map', 'each', 'isNumber', 'isString', 'isNaN', 'isArray', 'isObject', 'find', 'defer', 'delay', 'max', 'min', 'sortBy', 'flatten', 'clone', 'cloneDeep', 'values', 'pick', 'reduce', 'filter', 'indexOf', 'keys', 'debounce'],
                }
            }
        },
        cssmin: {
            minify: {
                expand: true,
                cwd: 'build/tmp/',
                src: ['razorflow.css'],
                dest: 'build/assets/css',
                ext: '.min.css'
            }
        },
        // Need to copy products.json
        copy: {
            localToWebRF: {
                files: [
                    {src: ["build/js/razorflow.min.js"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/css/razorflow.min.css"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/js/templates.js"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/js/rfDemos.js"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/img/exampleImgs/*.png"], dest: '../webrf/backend/static/transfer/',flatten: true },
                ]
            }
        },
        copyto: {
            srcToBuild: {
                files: [
                    {cwd: 'src/vendor/js/', src: ['jquery.min.js'], dest: 'build/assets/js/'},
                ]
            },
            packageToBuild: {
                files: [
                    {cwd: 'src/package/', src: ['**/*'], dest: 'build/package/'},
                ],
            },
            assetsToPackage: {
                files: [
                    {cwd: 'build/assets/', src: ["js/**", "css/**"], dest: 'build/package/files/'},
                    {cwd: 'build/assets/', src: ["js/**", "css/**"], dest: 'build/package/dashboard_quickstart/'},
                ],
            },
            packageToRelease: {
                files: [
                    {cwd: 'src/package/', src: ['**'], dest: '../package/rf/javascript/'}
                ]
            },
            razorcharts: {
                files: [
                    {cwd: '../razorcharts/src/js', src:['**'], dest: 'src/js/'}
                ]
            },
            spriteDev: {
                files: [
                    {cwd: 'src/img/', src:['**'], dest: 'build/tmp/'}
                ]
            },
            spriteProd: {
                files: [
                    {cwd: 'src/img/', src:['**'], dest: 'build/assets/img/'}
                ]
            },
            themebuilder: {
                files: [
                    {cwd: 'src/less/', src: ["theme.less", "mixins.less", "theme/default.less"], dest: 'build/tmp/themebuilder/'},
                    {cwd: 'src/js/generated/', src: ["defaulttheme.json"], dest: 'build/tmp/themebuilder/'}
                ]
            }
        },
        replace: {
            removeAMD: {
                src: "build/assets/js/razorflow.min.js",
                overwrite: true,
                replacements: [
                    {from: /\bdefine\b/g, to: "_dfn"},
                    {from: /\brequire\b/g, to: "_rqr"}
                ]
            }
        },
        clean: {
            build: ["build"]
        },
        themegen: {
            defaultTheme: {
                options: {
                    themeJSON: "src/js/generated/defaulttheme.json",
                    out: "build/tmp/less/rftheme.default.less"
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-contrib-jst');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-lodash');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-text-replace');
    grunt.loadNpmTasks('grunt-copy-to');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadTasks("./tools/src/grunt-tasks");

    grunt.registerTask('compile', ['themegen', 'less', 'jst:compile', 'copyto:spriteDev', 'copyto:themebuilder']);
    grunt.registerTask('test', ['compile', 'karma:dev', 'shell:coverageReport']);

    grunt.registerTask('build', ["clean:build", "less", "jst:compile", 'requirejs:core', 'requirejs:wrapper', "replace:removeAMD", 'cssmin:minify', "copyto:srcToBuild", "copyto:spriteProd"])
    grunt.registerTask('package', ['build', 'copyto:packageToBuild', 'copyto:assetsToPackage'])
    // grunt.registerTask('websiteRelease', ['build', 'cssmin:minify', 'squashdemos', "screenshotGen:examples", 'copy:localToWebRF'])
}<commit_msg>moved defaulttheme.json to config in themebuilder<commit_after>var gruntRequireConfig = require('./src/dev/requireConfig').gruntConfig;
var gruntWrapperRequireConfig = require('./src/dev/requireConfig').gruntWrapperConfig;

module.exports = function (grunt) {
    grunt.initConfig({
        requirejs: {
            core: {
                options: gruntRequireConfig
            },
            wrapper: {
                options: gruntWrapperRequireConfig
            }
        },
        concat: {

        },
        jst: {
            compile: {
                options: {
                    prettify: true,
                    processName: function (filePath) {
                        var parts = filePath.split('/');
                        var fileName = parts[parts.length - 1];
                        return fileName.split('.')[0];
                    },
                    amd: true
                },
                files: {
                    "src/js/generated/templates.js": ["src/templates/*.html"]
                }
            }
        },
        less: {
            development: {
                options: {
                    paths: ['src/less']
                },
                files: {
                    "build/tmp/razorflow.css": "src/less/razorflow.less"
                }
            },
            newdesign: {
                options: {
                    paths: ['src/dev/newdesign/less']
                },
                files: {
                    "src/dev/newdesign/css/razorflow.css":  "src/dev/newdesign/less/razorflow.less"
                }
            },
            theme: {
                files: {
                    "build/tmp/rftheme.default.css": "build/tmp/less/rftheme.default.less"
                }
            }
        },
        jshint: {
            options: {
                jshintrc: 'src/js/.jshintrc'
            },
            files: [
                "src/js/**/*.js"
            ]
        },
        karma: {
            dev: {
                configFile: './karma.conf.js',
                singleRun: true
            }
        },
        lodash: {
            build: {
                dest: 'src/vendor/js/lodash.rf.js',
                options: {
                    include: ['extend', 'pluck', 'map', 'each', 'isNumber', 'isString', 'isNaN', 'isArray', 'isObject', 'find', 'defer', 'delay', 'max', 'min', 'sortBy', 'flatten', 'clone', 'cloneDeep', 'values', 'pick', 'reduce', 'filter', 'indexOf', 'keys', 'debounce'],
                }
            }
        },
        cssmin: {
            minify: {
                expand: true,
                cwd: 'build/tmp/',
                src: ['razorflow.css'],
                dest: 'build/assets/css',
                ext: '.min.css'
            }
        },
        // Need to copy products.json
        copy: {
            localToWebRF: {
                files: [
                    {src: ["build/js/razorflow.min.js"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/css/razorflow.min.css"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/js/templates.js"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/js/rfDemos.js"], dest: '../webrf/backend/static/transfer/', flatten:true},
                    {src: ["build/img/exampleImgs/*.png"], dest: '../webrf/backend/static/transfer/',flatten: true },
                ]
            }
        },
        copyto: {
            srcToBuild: {
                files: [
                    {cwd: 'src/vendor/js/', src: ['jquery.min.js'], dest: 'build/assets/js/'},
                ]
            },
            packageToBuild: {
                files: [
                    {cwd: 'src/package/', src: ['**/*'], dest: 'build/package/'},
                ],
            },
            assetsToPackage: {
                files: [
                    {cwd: 'build/assets/', src: ["js/**", "css/**"], dest: 'build/package/files/'},
                    {cwd: 'build/assets/', src: ["js/**", "css/**"], dest: 'build/package/dashboard_quickstart/'},
                ],
            },
            packageToRelease: {
                files: [
                    {cwd: 'src/package/', src: ['**'], dest: '../package/rf/javascript/'}
                ]
            },
            razorcharts: {
                files: [
                    {cwd: '../razorcharts/src/js', src:['**'], dest: 'src/js/'}
                ]
            },
            spriteDev: {
                files: [
                    {cwd: 'src/img/', src:['**'], dest: 'build/tmp/'}
                ]
            },
            spriteProd: {
                files: [
                    {cwd: 'src/img/', src:['**'], dest: 'build/assets/img/'}
                ]
            },
            themebuilder: {
                files: [
                    {cwd: 'src/less/', src: ["theme.less", "mixins.less", "theme/default.less"], dest: 'build/tmp/themebuilder/'},
                    {cwd: 'src/js/themebuilder/config/', src: ["defaulttheme.json"], dest: 'build/tmp/themebuilder/'}
                ]
            }
        },
        replace: {
            removeAMD: {
                src: "build/assets/js/razorflow.min.js",
                overwrite: true,
                replacements: [
                    {from: /\bdefine\b/g, to: "_dfn"},
                    {from: /\brequire\b/g, to: "_rqr"}
                ]
            }
        },
        clean: {
            build: ["build"]
        },
        themegen: {
            defaultTheme: {
                options: {
                    themeJSON: "src/js/themebuilder/config/defaulttheme.json",
                    out: "build/tmp/less/rftheme.default.less"
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-contrib-jst');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-lodash');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-text-replace');
    grunt.loadNpmTasks('grunt-copy-to');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadTasks("./tools/src/grunt-tasks");

    grunt.registerTask('compile', ['themegen', 'less', 'jst:compile', 'copyto:spriteDev', 'copyto:themebuilder']);
    grunt.registerTask('test', ['compile', 'karma:dev', 'shell:coverageReport']);

    grunt.registerTask('build', ["clean:build", "less", "jst:compile", 'requirejs:core', 'requirejs:wrapper', "replace:removeAMD", 'cssmin:minify', "copyto:srcToBuild", "copyto:spriteProd"])
    grunt.registerTask('package', ['build', 'copyto:packageToBuild', 'copyto:assetsToPackage'])
    // grunt.registerTask('websiteRelease', ['build', 'cssmin:minify', 'squashdemos', "screenshotGen:examples", 'copy:localToWebRF'])
}<|endoftext|>


<commit_before>// Generated on 2013-10-18 using generator-angular 0.5.0
'use strict';

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

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

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

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

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

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

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

  grunt.registerTask('default', [
    'jshint',
    'test',
    'build'
  ]);
};
<commit_msg>test and build as default grunt target<commit_after>// Generated on 2013-10-18 using generator-angular 0.5.0
'use strict';

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

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

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

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

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

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

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

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


<commit_before>'use strict';

module.exports = function(grunt) {
    var _ = require('lodash');
    var path = require('path');
    var through = require('through2');
    var proxyquire = require('proxyquireify');
    var versionify = require('browserify-versionify');
    var derequire = require('derequire/plugin');

    var excludedPlugins = [
        'react-native'
    ];

    var plugins = grunt.option('plugins');
    // Create plugin paths and verify they exist
    plugins = _.map(plugins ? plugins.split(',') : [], function (plugin) {
        var p = 'plugins/' + plugin + '.js';

        if(!grunt.file.exists(p))
            throw new Error("Plugin '" + plugin + "' not found in plugins directory.");

        return p;
    });

    // custom browserify transformer to re-write plugins to
    // self-register with Raven via addPlugin
    function AddPluginBrowserifyTransformer() {
        return function (file) {
            return through(function (buf, enc, next) {
                buf = buf.toString('utf8');
                if (/plugins/.test(file)) {
                    buf += "\nrequire('../src/singleton').addPlugin(module.exports);";
                }
                this.push(buf);
                next();
            });
        };
    }

    // Taken from http://dzone.com/snippets/calculate-all-combinations
    var combine = function (a) {
        var fn = function (n, src, got, all) {
            if (n === 0) {
                all.push(got);
                return;
            }

            for (var j = 0; j < src.length; j++) {
                fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
            }
        };

        var excluded = _.map(excludedPlugins, function(plugin) {
            return 'plugins/' + plugin + '.js';
        });

        // Remove the plugins that we don't want to build
        a = _.filter(a, function(n) {
            return excluded.indexOf(n) === -1;
        });

        var all = [a];

        for (var i = 0; i < a.length; i++) {
            fn(i, a, [], all);
        }

        return all;
    };

    var plugins = grunt.file.expand('plugins/*.js');

    var cleanedPlugins = plugins.filter(function (plugin) {
        var pluginName = path.basename(plugin, '.js');

        return excludedPlugins.indexOf(pluginName) === -1;
    });

    var pluginSingleFiles = cleanedPlugins.map(function (plugin) {
        var filename = path.basename(plugin);

        var file = {};
        file.src = plugin;
        file.dest = path.join('build', 'plugins', filename);

        return file;
    });

    var pluginCombinations = combine(plugins);
    var pluginConcatFiles = _.reduce(pluginCombinations, function (dict, comb) {
        var key = _.map(comb, function (plugin) {
            return path.basename(plugin, '.js');
        });
        key.sort();

        var dest = path.join('build/', key.join(','), '/raven.js');
        dict[dest] = ['src/singleton.js'].concat(comb);

        return dict;
    }, {});

    var browserifyConfig = {
        options: {
            banner: grunt.file.read('template/_copyright.js'),
                browserifyOptions: {
                standalone: 'Raven' // umd
            },
            transform: [ versionify ],
                plugin: [ derequire ]
        },
        core: {
            src: 'src/singleton.js',
            dest: 'build/raven.js'
        },
        'plugins-combined': {
            files: pluginConcatFiles,
                options: {
                transform: [
                    [ versionify ],
                    [ new AddPluginBrowserifyTransformer() ]
                ]
            }
        },
        test: {
            src: 'test/**/*.test.js',
                dest: 'build/raven.test.js',
                options: {
                browserifyOptions: {
                    debug: true // source maps
                },
                plugin: [proxyquire.plugin]
            }
        }
    };

    // Create a dedicated entry in browserify config for
    // each individual plugin (each needs a unique `standalone`
    // config)
    var browserifyPluginTaskNames = [];
    pluginSingleFiles.forEach(function (item) {
        var name = item.src
            .replace(/.*\//, '') // everything before slash
            .replace('.js', ''); // extension
        var capsName = name.charAt(0).toUpperCase() + name.slice(1);
        var config = {
            src: item.src,
            dest: item.dest,
            options: {
                browserifyOptions: {
                    // e.g. Raven.Plugins.Angular
                    standalone: 'Raven.Plugins.' + capsName
                }
            }
        };
        browserifyConfig[name] = config;
        browserifyPluginTaskNames.push('browserify:' + name);
    });

    var gruntConfig = {
        pkg: grunt.file.readJSON('package.json'),
        aws: grunt.file.exists('aws.json') ? grunt.file.readJSON('aws.json'): {},

        clean: ['build'],

        browserify: browserifyConfig,

        uglify: {
            options: {
                sourceMap: true,

                // Only preserve comments that start with (!)
                preserveComments: /^!/,
                compress: {
                    dead_code: true,
                    global_defs: {
                        'TEST': false
                    }
                }
            },
            dist: {
                src: ['build/**/*.js'],
                ext: '.min.js',
                expand: true
            }
        },

        eslint: {
            target: ['Gruntfile.js', 'src/**/*.js', 'plugins/**/*.js']
        },

        mocha: {
            options: {
                mocha: {
                    ignoreLeaks: true,
                    grep: grunt.option('grep')
                },
                log: true,
                reporter: 'Dot',
                run: true
            },
            unit: {
                src: ['test/index.html'],
                nonull: true
            },
            integration: {
                src: ['test/integration/index.html'],
                nonull: true
            }
        },

        release: {
            options: {
                npm: false,
                commitMessage: 'Release <%= version %>'
            }
        },

        s3: {
            options: {
                key: '<%= aws.key %>',
                secret: '<%= aws.secret %>',
                bucket: '<%= aws.bucket %>',
                access: 'public-read',
                // Limit concurrency
                maxOperations: 20,
                headers: {
                    // Surrogate-Key header for Fastly to purge by release
                    'x-amz-meta-surrogate-key': '<%= pkg.release %>'
                }
            },
            all: {
                upload: [{
                    src: 'build/**/*',
                    dest: '<%= pkg.release %>/',
                    rel: 'build/'
                }]
            }
        },

        connect: {
            test: {
                options: {
                    port: 8000,
                    debug: true,
                    keepalive: true
                }
            },

            docs: {
                options: {
                    port: 8000,
                    debug: true,
                    base: 'docs/_build/html',
                    keepalive: true
                }
            }
        },

        copy: {
            dist: {
                expand: true,
                flatten: false,
                cwd: 'build/',
                src: '**',
                dest: 'dist/'
            }
        },

        sri: {
            dist: {
                src: ['dist/*.js'],
                options: {
                    dest: 'dist/sri.json',
                    pretty: true
                }
            },
            build: {
                src: ['build/**/*.js'],
                options: {
                    dest: 'build/sri.json',
                    pretty: true
                }
            }
        }
    };

    grunt.initConfig(gruntConfig);

    // Custom Grunt tasks
    grunt.registerTask('version', function() {
        var pkg = grunt.config.get('pkg');

        // Verify version string in source code matches what's in package.json
        var Raven = require('./src/raven');
        if (Raven.prototype.VERSION !== pkg.version) {
            return grunt.util.error('Mismatched version in src/raven.js: ' + Raven.prototype.VERSION +
                ' (should be ' + pkg.version + ')');
        }

        if (grunt.option('dev')) {
            pkg.release = 'dev';
        } else {
            pkg.release = pkg.version;
        }
        grunt.config.set('pkg', pkg);
    });

    // Grunt contrib tasks
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');

    // 3rd party Grunt tasks
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-mocha');
    grunt.loadNpmTasks('grunt-release');
    grunt.loadNpmTasks('grunt-s3');
    grunt.loadNpmTasks('grunt-gitinfo');
    grunt.loadNpmTasks('grunt-sri');
    grunt.loadNpmTasks('grunt-eslint');

    // Build tasks
    grunt.registerTask('_prep', ['clean', 'gitinfo', 'version']);
    grunt.registerTask('browserify.core', ['_prep', 'browserify:core'].concat(browserifyPluginTaskNames));
    grunt.registerTask('browserify.plugins-combined', ['_prep', 'browserify:plugins-combined']);
    grunt.registerTask('build.test', ['_prep', 'browserify:test']);
    grunt.registerTask('build.core', ['browserify.core', 'uglify', 'sri:dist']);
    grunt.registerTask('build.plugins-combined', ['browserify.plugins-combined', 'uglify', 'sri:dist', 'sri:build']);
    grunt.registerTask('build', ['build.plugins-combined']);
    grunt.registerTask('dist', ['build.core', 'copy:dist']);

    // Test task
    grunt.registerTask('test', ['eslint', 'browserify.core', 'browserify:test', 'mocha']);

    // Webserver tasks
    grunt.registerTask('run:test', ['connect:test']);
    grunt.registerTask('run:docs', ['connect:docs']);

    grunt.registerTask('publish', ['test', 'build.all', 's3']);
    grunt.registerTask('default', ['test']);
};
<commit_msg>Fix publish grunt task<commit_after>'use strict';

module.exports = function(grunt) {
    var _ = require('lodash');
    var path = require('path');
    var through = require('through2');
    var proxyquire = require('proxyquireify');
    var versionify = require('browserify-versionify');
    var derequire = require('derequire/plugin');

    var excludedPlugins = [
        'react-native'
    ];

    var plugins = grunt.option('plugins');
    // Create plugin paths and verify they exist
    plugins = _.map(plugins ? plugins.split(',') : [], function (plugin) {
        var p = 'plugins/' + plugin + '.js';

        if(!grunt.file.exists(p))
            throw new Error("Plugin '" + plugin + "' not found in plugins directory.");

        return p;
    });

    // custom browserify transformer to re-write plugins to
    // self-register with Raven via addPlugin
    function AddPluginBrowserifyTransformer() {
        return function (file) {
            return through(function (buf, enc, next) {
                buf = buf.toString('utf8');
                if (/plugins/.test(file)) {
                    buf += "\nrequire('../src/singleton').addPlugin(module.exports);";
                }
                this.push(buf);
                next();
            });
        };
    }

    // Taken from http://dzone.com/snippets/calculate-all-combinations
    var combine = function (a) {
        var fn = function (n, src, got, all) {
            if (n === 0) {
                all.push(got);
                return;
            }

            for (var j = 0; j < src.length; j++) {
                fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
            }
        };

        var excluded = _.map(excludedPlugins, function(plugin) {
            return 'plugins/' + plugin + '.js';
        });

        // Remove the plugins that we don't want to build
        a = _.filter(a, function(n) {
            return excluded.indexOf(n) === -1;
        });

        var all = [a];

        for (var i = 0; i < a.length; i++) {
            fn(i, a, [], all);
        }

        return all;
    };

    var plugins = grunt.file.expand('plugins/*.js');

    var cleanedPlugins = plugins.filter(function (plugin) {
        var pluginName = path.basename(plugin, '.js');

        return excludedPlugins.indexOf(pluginName) === -1;
    });

    var pluginSingleFiles = cleanedPlugins.map(function (plugin) {
        var filename = path.basename(plugin);

        var file = {};
        file.src = plugin;
        file.dest = path.join('build', 'plugins', filename);

        return file;
    });

    var pluginCombinations = combine(plugins);
    var pluginConcatFiles = _.reduce(pluginCombinations, function (dict, comb) {
        var key = _.map(comb, function (plugin) {
            return path.basename(plugin, '.js');
        });
        key.sort();

        var dest = path.join('build/', key.join(','), '/raven.js');
        dict[dest] = ['src/singleton.js'].concat(comb);

        return dict;
    }, {});

    var browserifyConfig = {
        options: {
            banner: grunt.file.read('template/_copyright.js'),
                browserifyOptions: {
                standalone: 'Raven' // umd
            },
            transform: [ versionify ],
                plugin: [ derequire ]
        },
        core: {
            src: 'src/singleton.js',
            dest: 'build/raven.js'
        },
        'plugins-combined': {
            files: pluginConcatFiles,
                options: {
                transform: [
                    [ versionify ],
                    [ new AddPluginBrowserifyTransformer() ]
                ]
            }
        },
        test: {
            src: 'test/**/*.test.js',
                dest: 'build/raven.test.js',
                options: {
                browserifyOptions: {
                    debug: true // source maps
                },
                plugin: [proxyquire.plugin]
            }
        }
    };

    // Create a dedicated entry in browserify config for
    // each individual plugin (each needs a unique `standalone`
    // config)
    var browserifyPluginTaskNames = [];
    pluginSingleFiles.forEach(function (item) {
        var name = item.src
            .replace(/.*\//, '') // everything before slash
            .replace('.js', ''); // extension
        var capsName = name.charAt(0).toUpperCase() + name.slice(1);
        var config = {
            src: item.src,
            dest: item.dest,
            options: {
                browserifyOptions: {
                    // e.g. Raven.Plugins.Angular
                    standalone: 'Raven.Plugins.' + capsName
                }
            }
        };
        browserifyConfig[name] = config;
        browserifyPluginTaskNames.push('browserify:' + name);
    });

    var gruntConfig = {
        pkg: grunt.file.readJSON('package.json'),
        aws: grunt.file.exists('aws.json') ? grunt.file.readJSON('aws.json'): {},

        clean: ['build'],

        browserify: browserifyConfig,

        uglify: {
            options: {
                sourceMap: true,

                // Only preserve comments that start with (!)
                preserveComments: /^!/,
                compress: {
                    dead_code: true,
                    global_defs: {
                        'TEST': false
                    }
                }
            },
            dist: {
                src: ['build/**/*.js'],
                ext: '.min.js',
                expand: true
            }
        },

        eslint: {
            target: ['Gruntfile.js', 'src/**/*.js', 'plugins/**/*.js']
        },

        mocha: {
            options: {
                mocha: {
                    ignoreLeaks: true,
                    grep: grunt.option('grep')
                },
                log: true,
                reporter: 'Dot',
                run: true
            },
            unit: {
                src: ['test/index.html'],
                nonull: true
            },
            integration: {
                src: ['test/integration/index.html'],
                nonull: true
            }
        },

        release: {
            options: {
                npm: false,
                commitMessage: 'Release <%= version %>'
            }
        },

        s3: {
            options: {
                key: '<%= aws.key %>',
                secret: '<%= aws.secret %>',
                bucket: '<%= aws.bucket %>',
                access: 'public-read',
                // Limit concurrency
                maxOperations: 20,
                headers: {
                    // Surrogate-Key header for Fastly to purge by release
                    'x-amz-meta-surrogate-key': '<%= pkg.release %>'
                }
            },
            all: {
                upload: [{
                    src: 'build/**/*',
                    dest: '<%= pkg.release %>/',
                    rel: 'build/'
                }]
            }
        },

        connect: {
            test: {
                options: {
                    port: 8000,
                    debug: true,
                    keepalive: true
                }
            },

            docs: {
                options: {
                    port: 8000,
                    debug: true,
                    base: 'docs/_build/html',
                    keepalive: true
                }
            }
        },

        copy: {
            dist: {
                expand: true,
                flatten: false,
                cwd: 'build/',
                src: '**',
                dest: 'dist/'
            }
        },

        sri: {
            dist: {
                src: ['dist/*.js'],
                options: {
                    dest: 'dist/sri.json',
                    pretty: true
                }
            },
            build: {
                src: ['build/**/*.js'],
                options: {
                    dest: 'build/sri.json',
                    pretty: true
                }
            }
        }
    };

    grunt.initConfig(gruntConfig);

    // Custom Grunt tasks
    grunt.registerTask('version', function() {
        var pkg = grunt.config.get('pkg');

        // Verify version string in source code matches what's in package.json
        var Raven = require('./src/raven');
        if (Raven.prototype.VERSION !== pkg.version) {
            return grunt.util.error('Mismatched version in src/raven.js: ' + Raven.prototype.VERSION +
                ' (should be ' + pkg.version + ')');
        }

        if (grunt.option('dev')) {
            pkg.release = 'dev';
        } else {
            pkg.release = pkg.version;
        }
        grunt.config.set('pkg', pkg);
    });

    // Grunt contrib tasks
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');

    // 3rd party Grunt tasks
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-mocha');
    grunt.loadNpmTasks('grunt-release');
    grunt.loadNpmTasks('grunt-s3');
    grunt.loadNpmTasks('grunt-gitinfo');
    grunt.loadNpmTasks('grunt-sri');
    grunt.loadNpmTasks('grunt-eslint');

    // Build tasks
    grunt.registerTask('_prep', ['clean', 'gitinfo', 'version']);
    grunt.registerTask('browserify.core', ['_prep', 'browserify:core'].concat(browserifyPluginTaskNames));
    grunt.registerTask('browserify.plugins-combined', ['_prep', 'browserify:plugins-combined']);
    grunt.registerTask('build.test', ['_prep', 'browserify:test']);
    grunt.registerTask('build.core', ['browserify.core', 'uglify', 'sri:dist']);
    grunt.registerTask('build.plugins-combined', ['browserify.plugins-combined', 'uglify', 'sri:dist', 'sri:build']);
    grunt.registerTask('build', ['build.plugins-combined']);
    grunt.registerTask('dist', ['build.core', 'copy:dist']);

    // Test task
    grunt.registerTask('test', ['eslint', 'browserify.core', 'browserify:test', 'mocha']);

    // Webserver tasks
    grunt.registerTask('run:test', ['connect:test']);
    grunt.registerTask('run:docs', ['connect:docs']);

    grunt.registerTask('publish', ['test', 'build.plugins-combined', 's3']);
    grunt.registerTask('default', ['test']);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

    grunt.loadTasks('tasks');
    grunt.loadNpmTasks('grunt-mocha-test');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jsdoc');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        mochaTest: {
            unit: {
                options: {
                    reporter: 'spec'
                },
                src: ['test/**/*.js']
            },
            functional: {
                options: {
                    reporter: 'spec'
                },
                src: ['functionalTest/**/*.js']
            },
            performance: {
                options: {
                    reporter: 'spec'
                },
                src: ['performanceTest/**/*.js']
            },
            coverage: {
                options: {
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: 'coverage.html',
                    require: 'coverage/blanket'
                },
                src: ['test/**/*.js']
            }
        },
        jshint: {
            all: [
                'Gruntfile.js',
                'src/**/*.js',
                'tasks/**/*.js',
                'test/**/*.js',
                'functionalTest/**/*.js',
                'performanceTest/**/*.js',
                'bin/mb'
            ],
            options: {
                ignores: [
                    'src/public/scripts/jquery/**/*.js'
                ],
                node: true,
                globals: {
                    describe: false,
                    it: false,
                    before: false,
                    beforeEach: false,
                    after: false,
                    afterEach: false
                },
                newcap: false,
                camelcase: true,
                curly: true,
                eqeqeq: true,
                latedef: true,
                undef: true,
                unused: true,
                trailing: true,
                maxparams: 4,
                maxdepth: 3,
                maxcomplexity: 5
            }
        },
        jsdoc : {
            dist : {
                src: ['src/**/*.js'],
                options: {
                    destination: 'docs',
                    configure: '.jsdoc',
                    pedantic: true,
                    readme: 'CONTRIBUTING.md',
                    package: 'dist/mountebank/package.json' // use dist to get correct version
                }
            }
        }
    });

    grunt.registerTask('setAirplaneMode', function () {
        process.env.MB_AIRPLANE_MODE = 'true';
    });

    grunt.registerTask('test:unit', 'Run the unit tests', ['mochaTest:unit']);
    grunt.registerTask('test:functional', 'Run the functional tests',
        ['mb:start', 'try', 'mochaTest:functional', 'finally', 'mb:stop', 'checkForErrors']);
    grunt.registerTask('test:performance', 'Run the performance tests', ['mochaTest:performance']);
    grunt.registerTask('test', 'Run all non-performance tests', ['test:unit', 'test:functional']);
    grunt.registerTask('coverage', 'Generate code coverage', ['mochaTest:coverage']);
    grunt.registerTask('lint', 'Run all JavaScript lint checks', ['wsCheck', 'jsCheck', 'deadCheck', 'jshint']);
    grunt.registerTask('default', ['dist', 'version', 'test', 'lint']);

    grunt.registerTask('local', 'Fast build for local development (avoids distribution)', ['test', 'lint']);
    grunt.registerTask('airplane', 'Build that avoids tests requiring network access', ['setAirplaneMode', 'local']);

    // Package-specific testing
    grunt.registerTask('test:tarball:x64', 'Run tests against packaged tarball',
        ['dist', 'version', 'dist:tarball:x64', 'install:tarball:x64', 'test', 'lint']);
    grunt.registerTask('test:zip', 'Run tests against packaged zipfile',
        ['download:zip', 'install:zip', 'test', 'lint']);
    grunt.registerTask('test:npm', 'Run tests against npm package',
        ['dist', 'version', 'dist:npm', 'install:npm', 'test']);
    grunt.registerTask('test:pkg', 'Run tests against OSX pkg file',
        ['dist', 'version', 'dist:package:osxpkg', 'install:pkg', 'test']);
    grunt.registerTask('test:deb', 'Run tests against Debian package',
        ['dist', 'version', 'dist:package:deb', 'install:deb', 'test', 'uninstall:deb']);
    grunt.registerTask('test:rpm', 'Run tests against Red Hat package',
        ['download:rpm', 'install:rpm', 'test', 'uninstall:rpm']);
};
<commit_msg>Removing dead code<commit_after>'use strict';

module.exports = function (grunt) {

    grunt.loadTasks('tasks');
    grunt.loadNpmTasks('grunt-mocha-test');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jsdoc');

    grunt.initConfig({
        mochaTest: {
            unit: {
                options: {
                    reporter: 'spec'
                },
                src: ['test/**/*.js']
            },
            functional: {
                options: {
                    reporter: 'spec'
                },
                src: ['functionalTest/**/*.js']
            },
            performance: {
                options: {
                    reporter: 'spec'
                },
                src: ['performanceTest/**/*.js']
            },
            coverage: {
                options: {
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: 'coverage.html',
                    require: 'coverage/blanket'
                },
                src: ['test/**/*.js']
            }
        },
        jshint: {
            all: [
                'Gruntfile.js',
                'src/**/*.js',
                'tasks/**/*.js',
                'test/**/*.js',
                'functionalTest/**/*.js',
                'performanceTest/**/*.js',
                'bin/mb'
            ],
            options: {
                ignores: [
                    'src/public/scripts/jquery/**/*.js'
                ],
                node: true,
                globals: {
                    describe: false,
                    it: false,
                    before: false,
                    beforeEach: false,
                    after: false,
                    afterEach: false
                },
                newcap: false,
                camelcase: true,
                curly: true,
                eqeqeq: true,
                latedef: true,
                undef: true,
                unused: true,
                trailing: true,
                maxparams: 4,
                maxdepth: 3,
                maxcomplexity: 5
            }
        },
        jsdoc : {
            dist : {
                src: ['src/**/*.js'],
                options: {
                    destination: 'docs',
                    configure: '.jsdoc',
                    pedantic: true,
                    readme: 'CONTRIBUTING.md',
                    package: 'dist/mountebank/package.json' // use dist to get correct version
                }
            }
        }
    });

    grunt.registerTask('setAirplaneMode', function () {
        process.env.MB_AIRPLANE_MODE = 'true';
    });

    grunt.registerTask('test:unit', 'Run the unit tests', ['mochaTest:unit']);
    grunt.registerTask('test:functional', 'Run the functional tests',
        ['mb:start', 'try', 'mochaTest:functional', 'finally', 'mb:stop', 'checkForErrors']);
    grunt.registerTask('test:performance', 'Run the performance tests', ['mochaTest:performance']);
    grunt.registerTask('test', 'Run all non-performance tests', ['test:unit', 'test:functional']);
    grunt.registerTask('coverage', 'Generate code coverage', ['mochaTest:coverage']);
    grunt.registerTask('lint', 'Run all JavaScript lint checks', ['wsCheck', 'jsCheck', 'deadCheck', 'jshint']);
    grunt.registerTask('default', ['dist', 'version', 'test', 'lint']);

    grunt.registerTask('local', 'Fast build for local development (avoids distribution)', ['test', 'lint']);
    grunt.registerTask('airplane', 'Build that avoids tests requiring network access', ['setAirplaneMode', 'local']);

    // Package-specific testing
    grunt.registerTask('test:tarball:x64', 'Run tests against packaged tarball',
        ['dist', 'version', 'dist:tarball:x64', 'install:tarball:x64', 'test', 'lint']);
    grunt.registerTask('test:zip', 'Run tests against packaged zipfile',
        ['download:zip', 'install:zip', 'test', 'lint']);
    grunt.registerTask('test:npm', 'Run tests against npm package',
        ['dist', 'version', 'dist:npm', 'install:npm', 'test']);
    grunt.registerTask('test:pkg', 'Run tests against OSX pkg file',
        ['dist', 'version', 'dist:package:osxpkg', 'install:pkg', 'test']);
    grunt.registerTask('test:deb', 'Run tests against Debian package',
        ['dist', 'version', 'dist:package:deb', 'install:deb', 'test', 'uninstall:deb']);
    grunt.registerTask('test:rpm', 'Run tests against Red Hat package',
        ['download:rpm', 'install:rpm', 'test', 'uninstall:rpm']);
};
<|endoftext|>


<commit_before>var superagent = require('superagent');
var expect = require('expect.js');

describe('wmcn api server', function() {

  var id = '54ea3402b6b58e1e14f2aef9';

  it('gets all users', function (done) {
    superagent.get('http://localhost:3000/users')
    .end(function (e,res) {
      // console.log(res.body);
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(res.body.users[0]._id.length).to.eql(24);
      // expect(res.body.users[0]._id).to.eql(id);
      done();
    });
  });

  it('gets a user', function (done) {
    superagent.get('http://localhost:3000/users/' + id)
    .end(function (e, res) {
      // console.log(res.body);
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(typeof res.body).to.eql('object');
      expect(res.body._id.length).to.eql(id.length);
      expect(res.body._id).to.eql(id);
      done();
    });
  });

  it('updates a user', function (done) {
    superagent.put('http://localhost:3000/users/' + id)
    // .send({
    //   id: id,
    //   firstName: 'test',
    //   lastName: 'Test'})
    .end(function (e, res) {
      // console.log(res.body);
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(typeof res.body).to.eql('object');
      expect(res.body.message).to.eql('User updated');
      done();
    });
  });

  it('adds a new user', function (done) {
    superagent.post('http://localhost:3000/users')
    .send({
      email: 'test@user.com',
      firstName: 'Jane',
      lastName: 'Doe',
      phone: 1234567890})
    .end(function (e, res) {
      // console.log(res.body);
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(201);
      expect(res.body.message).to.eql('User created: Jane');
      done();
    });
  });

  it('removes a user', function(done){
    superagent.del('http://localhost:3000/users' + id)
    // .send({
    //   id: id})
    .end(function(e, res){
      // console.log(res.body);
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(res.body.message).to.eql('User removed.');
      done();
    });
  });
});<commit_msg>add test/users<commit_after>var superagent = require('superagent');
var expect = require('expect.js');
var config = require('../config/config')();
var root = config.api_root_url;

describe('wmcn api server', function() {
  var id = process.env.ID;

  it('gets all users', function (done) {
    superagent.get(root + '/users')
    .end(function (e,res) {
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(res.body.users.length).to.be.above(0);
      done();
    });
  });

  it('adds a new user', function (done) {
    superagent.post(root + '/users')
    .end(function (e, res) {
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(201);
      expect(res.body.result).to.eql('1 user created.');
      var new_id = res.body.new_id;
      superagent.get(root + '/users/' + new_id)
      .end(function(e, res) {
        expect(e).to.eql(null);
        expect(res.statusCode).to.eql(200);
        expect(res.body.user.id).to.eql(new_id);
        done();
      });
    });
  });

  it('gets one user', function (done) {
    superagent.get(root + '/users/' + id)
    .end(function (e, res) {
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(typeof res.body).to.eql('object');
      done();
    });
  });
  //
  // it('updates a user', function (done) {
  //   superagent.put('http://localhost:3000/users/' + id)
  //   // .send({
  //   //   id: id,
  //   //   firstName: 'test',
  //   //   lastName: 'Test'})
  //   .end(function (e, res) {
  //     // console.log(res.body);
  //     expect(e).to.eql(null);
  //     expect(res.statusCode).to.eql(200);
  //     expect(typeof res.body).to.eql('object');
  //     expect(res.body.message).to.eql('User updated');
  //     done();
  //   });
  // });
  //

  it('removes a user', function(done){
    superagent.del(root + '/users/' + id)
    .end(function(e, res){
      expect(e).to.eql(null);
      expect(res.statusCode).to.eql(200);
      expect(res.body.message).to.eql('deleted user ' + id);

      superagent.get(root + '/users/' + id)
      .end(function(e, res) {
        expect(e).to.eql(null);
        expect(res.statusCode).to.eql(404);
        done();
      });
    });
  });
});
<|endoftext|>