| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 | /*jshint -W106 *//*jshint node:true, maxstatements: false, maxlen: false */var os = require("os");var path = require("path");var loadGruntTasks = require("load-grunt-tasks");module.exports = function(grunt) {  "use strict";  // Load necessary tasks  loadGruntTasks(grunt);  // Metadata  var pkg = grunt.file.readJSON("package.json");  // Make a temp dir for Flash compilation  var tmpDir = os.tmpdir ? os.tmpdir() : os.tmpDir();  var flashTmpDir = path.join(tmpDir, "zcflash");  // Shared configuration  var localPort = 7320;  // "ZERO"  // Project configuration.  var config = {    // Task configuration    jshint: {      options: {        jshintrc: true      },      gruntfile: ["Gruntfile.js"],      component: ["index.js"],      js: ["src/js/**/*.js", "!src/js/start.js", "!src/js/end.js"],      test: ["test/**/*.js"],      dist: ["dist/*.js", "!dist/*.min.js"]    },    flexpmd: {      flash: {        src: [flashTmpDir]      }    },    clean: {      dist: ["ZeroClipboard.*", "dist/ZeroClipboard.*"],      flash: {        options: {          // Force is required when trying to clean outside of the project dir          force: true        },        src: [flashTmpDir]      },      meta: ["bower.json", "composer.json", "LICENSE"],      coveralls: ["tmp/", "coverage/"]    },    concat: {      options: {        stripBanners: false,        process: {          data: pkg        }      },      core: {        src: [          "src/meta/source-banner.tmpl",          "src/js/start.js",          "src/js/shared/state.js",          "src/js/shared/private.js",          "src/js/core/state.js",          "src/js/core/private.js",          "src/js/core/api.js",          "src/js/end.js"        ],        dest: "dist/ZeroClipboard.Core.js"      },      client: {        src: [          "src/meta/source-banner.tmpl",          "src/js/start.js",          "src/js/shared/state.js",          "src/js/shared/private.js",          "src/js/core/state.js",          "src/js/core/private.js",          "src/js/core/api.js",          "src/js/client/state.js",          "src/js/client/private.js",          "src/js/client/api.js",          "src/js/end.js"        ],        dest: "dist/ZeroClipboard.js"      },      flash: {        files: [          {            src: [              "src/meta/source-banner.tmpl",              "src/flash/ZeroClipboard.as"            ],            dest: path.join(flashTmpDir, "ZeroClipboard.as")          },          {            src: [              "src/meta/source-banner.tmpl",              "src/flash/ClipboardInjector.as"            ],            dest: path.join(flashTmpDir, "ClipboardInjector.as")          },          {            src: [              "src/meta/source-banner.tmpl",              "src/flash/JsProxy.as"            ],            dest: path.join(flashTmpDir, "JsProxy.as")          },          {            src: [              "src/meta/source-banner.tmpl",              "src/flash/XssUtils.as"            ],            dest: path.join(flashTmpDir, "XssUtils.as")          }        ]      }    },    uglify: {      options: {        report: "min"      },      js: {        options: {          preserveComments: function(node, comment) {            return comment &&              comment.type === "comment2" &&              /^(!|\*|\*!)\r?\n/.test(comment.value);          },          beautify: {            beautify: true,            // `indent_level` requires jshint -W106            indent_level: 2          },          mangle: false,          compress: false        },        files: [          {            src: ["<%= concat.core.dest %>"],            dest: "<%= concat.core.dest %>"          },          {            src: ["<%= concat.client.dest %>"],            dest: "<%= concat.client.dest %>"          }        ]      },      minjs: {        options: {          preserveComments: function(node, comment) {            return comment &&              comment.type === "comment2" &&              /^(!|\*!)\r?\n/.test(comment.value);          },          sourceMap: true,          sourceMapName: function(dest) {            return dest.replace(".min.js", ".min.map");          },          // Bundles the contents of "`src`" into the "`dest`.map" source map file. This way,          // consumers only need to host the "*.min.js" and "*.min.map" files rather than          // needing to host all three files: "*.js", "*.min.js", and "*.min.map".          sourceMapIncludeSources: true        },        files: [          {            src: ["<%= concat.core.dest %>"],            dest: "dist/ZeroClipboard.Core.min.js"          },          {            src: ["<%= concat.client.dest %>"],            dest: "dist/ZeroClipboard.min.js"          }        ]      }    },    mxmlc: {      options: {        rawConfig: "-target-player=11.0.0 -static-link-runtime-shared-libraries=true"      },      swf: {        files: {          "dist/ZeroClipboard.swf": ["<%= concat.flash.files[0].dest %>"]        }      }    },    template: {      options: {        data: pkg      },      bower: {        files: {          "bower.json": ["src/meta/bower.json.tmpl"]        }      },      composer: {        files: {          "composer.json": ["src/meta/composer.json.tmpl"]        }      },      LICENSE: {        files: {          "LICENSE": ["src/meta/LICENSE.tmpl"]        }      }    },    chmod: {      options: {        mode: "444"      },      dist: ["dist/ZeroClipboard.*"],      meta: ["bower.json", "composer.json", "LICENSE"]    },    connect: {      server: {        options: {          port: localPort        }      }    },    qunit: {      file: [        "test/shared/private.tests.js.html",        "test/core/private.tests.js.html",        "test/core/api.tests.js.html",        "test/client/private.tests.js.html",        "test/client/api.tests.js.html",        "test/built/ZeroClipboard.Core.tests.js.html",        "test/built/ZeroClipboard.tests.js.html"        //"test/**/*.tests.js.html"      ],      http: {        options: {          urls:            grunt.file.expand([              "test/shared/private.tests.js.html",              "test/core/private.tests.js.html",              "test/core/api.tests.js.html",              "test/client/private.tests.js.html",              "test/client/api.tests.js.html",              "test/built/ZeroClipboard.Core.tests.js.html",              "test/built/ZeroClipboard.tests.js.html"              //"test/**/*.tests.js.html"            ]).map(function(testPage) {              return "http://localhost:" + localPort + "/" + testPage + "?noglobals=true";            })        }      },      coveralls: {        options: {          "--web-security": false,          timeout: 10000,          coverage: {            baseUrl: ".",            src: [              "src/js/**/*.js",              "!src/js/start.js",              "!src/js/end.js",              "dist/*.js",              "!dist/*.min.js"            ],            instrumentedFiles: "tmp",            htmlReport: "coverage/html",            lcovReport: "coverage/lcov",            statementsThresholdPct: 60.0,            disposeCollector: true          },          urls:            grunt.file.expand([              "test/shared/private.tests.js.html",              "test/core/private.tests.js.html",              "test/core/api.tests.js.html",              "test/client/private.tests.js.html",              "test/client/api.tests.js.html",              "test/built/ZeroClipboard.Core.tests.js.html",              "test/built/ZeroClipboard.tests.js.html"              //"test/**/*.tests.js.html"            ]).map(function(testPage) {              return "http://localhost:" + localPort + "/" + testPage + "?noglobals=true";            })        }      }    },    coveralls: {      options: {        force: true      },      all: {        src: "<%= qunit.coveralls.options.coverage.lcovReport %>/lcov.info"      }    },    watch: {      options: {        spawn: false      },      gruntfile: {        files: "<%= jshint.Gruntfile %>",        tasks: ["jshint:Gruntfile"]      },      js: {        files: "<%= jshint.js %>",        tasks: ["jshint:js", "unittest"]      },      test: {        files: "<%= jshint.test %>",        tasks: ["jshint:test", "unittest"]      }    }  };  grunt.initConfig(config);  // Task aliases and chains  grunt.registerTask("jshint-prebuild", ["jshint:gruntfile", "jshint:component", "jshint:js", "jshint:test"]);  grunt.registerTask("prep-flash",      ["clean:flash", "concat:flash"]);  grunt.registerTask("validate",        ["jshint-prebuild", "prep-flash", "flexpmd"]);  grunt.registerTask("build",           ["clean", "concat", "jshint:dist", "uglify", "mxmlc", "template", "chmod"]);  grunt.registerTask("build-travis",    ["clean", "concat", "jshint:dist", "mxmlc", "chmod:dist"]);  grunt.registerTask("test",            ["connect", "qunit:file", "qunit:http"]);  // Default task  grunt.registerTask("default", ["validate", "build", "test"]);  // Travis CI task  grunt.registerTask("travis",  ["validate", "build-travis", "test", "qunit:coveralls", "coveralls"]);};
 |