2013-02-13 07:40:08 +04:00
|
|
|
module.exports = function(grunt) {
|
2013-02-15 22:58:57 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-15 22:58:57 +04:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-compress");
|
2013-02-21 22:54:11 +04:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-concat");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-jshint");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-uglify");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-qunit");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-connect");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
2013-02-27 21:59:51 +04:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-clean");
|
2013-03-21 21:26:03 +04:00
|
|
|
grunt.loadNpmTasks("grunt-git-describe");
|
2013-02-15 22:58:57 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-21 23:56:16 +04:00
|
|
|
var distribution = "build/openseadragon/openseadragon.js",
|
|
|
|
minified = "build/openseadragon/openseadragon.min.js",
|
2013-03-25 21:02:41 +04:00
|
|
|
releaseRoot = "../site-build/built-openseadragon/",
|
2013-02-13 07:40:08 +04:00
|
|
|
sources = [
|
|
|
|
"src/openseadragon.js",
|
2013-03-07 00:36:52 +04:00
|
|
|
"src/fullscreen.js",
|
2013-02-13 07:40:08 +04:00
|
|
|
"src/eventhandler.js",
|
|
|
|
"src/mousetracker.js",
|
|
|
|
"src/control.js",
|
|
|
|
"src/controldock.js",
|
|
|
|
"src/viewer.js",
|
|
|
|
"src/navigator.js",
|
|
|
|
"src/strings.js",
|
|
|
|
"src/point.js",
|
|
|
|
//"src/profiler.js",
|
|
|
|
"src/tilesource.js",
|
|
|
|
"src/dzitilesource.js",
|
|
|
|
"src/iiiftilesource.js",
|
|
|
|
"src/osmtilesource.js",
|
|
|
|
"src/tmstilesource.js",
|
|
|
|
"src/legacytilesource.js",
|
|
|
|
"src/tilesourcecollection.js",
|
|
|
|
"src/button.js",
|
|
|
|
"src/buttongroup.js",
|
|
|
|
"src/rectangle.js",
|
|
|
|
"src/referencestrip.js",
|
|
|
|
"src/displayrectangle.js",
|
|
|
|
"src/spring.js",
|
|
|
|
"src/tile.js",
|
|
|
|
"src/overlay.js",
|
|
|
|
"src/drawer.js",
|
|
|
|
"src/viewport.js"
|
|
|
|
];
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-13 07:40:08 +04:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2013-02-21 22:54:11 +04:00
|
|
|
pkg: grunt.file.readJSON("package.json"),
|
2013-02-27 21:59:51 +04:00
|
|
|
clean: {
|
|
|
|
build: ["build"],
|
|
|
|
release: {
|
2013-03-25 21:02:41 +04:00
|
|
|
src: [releaseRoot],
|
2013-02-27 21:59:51 +04:00
|
|
|
options: {
|
|
|
|
force: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-02-13 07:40:08 +04:00
|
|
|
concat: {
|
2013-02-21 22:45:14 +04:00
|
|
|
options: {
|
2013-03-11 22:52:30 +04:00
|
|
|
banner: "//! <%= pkg.name %> <%= pkg.version %>\n"
|
|
|
|
+ "//! Built on <%= grunt.template.today('yyyy-mm-dd') %>\n"
|
2013-03-22 20:40:37 +04:00
|
|
|
+ "//! Git commit: <%= gitInfo %>\n"
|
2013-04-08 21:28:56 +04:00
|
|
|
+ "//! http://openseadragon.github.io\n\n",
|
2013-03-11 22:52:30 +04:00
|
|
|
process: true
|
2013-02-21 22:45:14 +04:00
|
|
|
},
|
2013-02-13 07:40:08 +04:00
|
|
|
dist: {
|
2013-02-15 00:02:17 +04:00
|
|
|
src: [ "<banner>" ].concat(sources),
|
2013-02-13 07:40:08 +04:00
|
|
|
dest: distribution
|
|
|
|
}
|
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
uglify: {
|
2013-03-11 22:52:30 +04:00
|
|
|
options: {
|
|
|
|
preserveComments: "some"
|
|
|
|
},
|
2013-02-14 22:21:35 +04:00
|
|
|
openseadragon: {
|
|
|
|
src: [ distribution ],
|
|
|
|
dest: minified
|
|
|
|
}
|
|
|
|
},
|
2013-02-15 22:58:57 +04:00
|
|
|
compress: {
|
|
|
|
zip: {
|
2013-02-21 23:56:16 +04:00
|
|
|
options: {
|
|
|
|
archive: "build/openseadragon.zip"
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
{ expand: true, cwd: "build/", src: ["openseadragon/**"] }
|
|
|
|
]
|
2013-02-15 22:58:57 +04:00
|
|
|
},
|
|
|
|
tar: {
|
2013-02-21 23:56:16 +04:00
|
|
|
options: {
|
2013-04-23 04:13:42 +04:00
|
|
|
archive: "build/openseadragon.tar.gz"
|
2013-02-21 23:56:16 +04:00
|
|
|
},
|
|
|
|
files: [
|
|
|
|
{ expand: true, cwd: "build/", src: [ "openseadragon/**" ] }
|
|
|
|
]
|
2013-02-15 22:58:57 +04:00
|
|
|
}
|
|
|
|
},
|
2013-02-14 22:21:35 +04:00
|
|
|
qunit: {
|
2013-02-21 23:17:05 +04:00
|
|
|
all: {
|
|
|
|
options: {
|
|
|
|
urls: [ "http://localhost:8000/test/test.html" ]
|
|
|
|
}
|
|
|
|
}
|
2013-02-14 22:21:35 +04:00
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
connect: {
|
2013-02-21 23:17:05 +04:00
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
port: 8000,
|
|
|
|
base: "."
|
|
|
|
}
|
2013-02-21 22:45:14 +04:00
|
|
|
}
|
2013-02-14 22:21:35 +04:00
|
|
|
},
|
|
|
|
watch: {
|
2013-03-12 21:43:27 +04:00
|
|
|
files: [ "Gruntfile.js", "src/*.js", "images/*" ],
|
2013-02-27 21:59:51 +04:00
|
|
|
tasks: "build"
|
2013-02-14 22:21:35 +04:00
|
|
|
},
|
2013-02-13 07:40:08 +04:00
|
|
|
jshint: {
|
|
|
|
options: {
|
2013-02-21 22:45:14 +04:00
|
|
|
browser: true,
|
|
|
|
eqeqeq: false,
|
|
|
|
loopfunc: false,
|
|
|
|
globals: {
|
|
|
|
OpenSeadragon: true
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
beforeconcat: sources,
|
|
|
|
afterconcat: [ distribution ]
|
2013-03-21 21:26:03 +04:00
|
|
|
},
|
|
|
|
"git-describe": {
|
2013-03-22 20:40:37 +04:00
|
|
|
build: {
|
2013-03-22 20:42:51 +04:00
|
|
|
options: {
|
|
|
|
prop: "gitInfo"
|
|
|
|
}
|
2013-03-21 21:26:03 +04:00
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Copy:build task.
|
|
|
|
// Copies the image files into the appropriate location in the build folder.
|
|
|
|
grunt.registerTask("copy:build", function() {
|
2013-02-15 01:24:50 +04:00
|
|
|
grunt.file.recurse("images", function(abspath, rootdir, subdir, filename) {
|
2013-02-21 23:56:16 +04:00
|
|
|
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
|
2013-02-15 01:24:50 +04:00
|
|
|
});
|
2013-03-25 20:51:58 +04:00
|
|
|
|
|
|
|
grunt.file.copy("changelog.txt", "build/changelog.txt");
|
2013-02-15 01:24:50 +04:00
|
|
|
});
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Copy:release task.
|
2013-03-25 21:02:41 +04:00
|
|
|
// Copies the contents of the build folder into the release folder.
|
2013-02-27 21:59:51 +04:00
|
|
|
grunt.registerTask("copy:release", function() {
|
|
|
|
grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) {
|
2013-03-25 21:02:41 +04:00
|
|
|
var dest = releaseRoot
|
2013-03-05 16:30:37 +04:00
|
|
|
+ (subdir ? subdir + "/" : '/')
|
2013-02-27 22:36:19 +04:00
|
|
|
+ filename;
|
|
|
|
|
|
|
|
grunt.file.copy(abspath, dest);
|
2013-02-27 21:59:51 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Build task.
|
|
|
|
// Cleans out the build folder and builds the code and images into it, checking lint.
|
|
|
|
grunt.registerTask("build", [
|
2013-03-21 21:26:03 +04:00
|
|
|
"clean:build", "jshint:beforeconcat", "git-describe", "concat", "jshint:afterconcat", "uglify", "copy:build"
|
2013-02-27 21:59:51 +04:00
|
|
|
]);
|
2013-02-14 22:21:35 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-14 22:21:35 +04:00
|
|
|
// Test task.
|
2013-02-27 21:59:51 +04:00
|
|
|
// Builds and runs unit tests.
|
|
|
|
grunt.registerTask("test", ["build", "connect", "qunit"]);
|
2013-02-13 07:40:08 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-15 22:58:57 +04:00
|
|
|
// Package task.
|
2013-04-23 04:13:42 +04:00
|
|
|
// Builds and creates the .zip and .tar.gz files.
|
2013-02-27 21:59:51 +04:00
|
|
|
grunt.registerTask("package", ["build", "compress"]);
|
2013-02-20 07:53:54 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Publish task.
|
2013-03-25 21:02:41 +04:00
|
|
|
// Cleans the built files out of the release folder and copies newly built ones over.
|
2013-02-27 21:59:51 +04:00
|
|
|
grunt.registerTask("publish", ["package", "clean:release", "copy:release"]);
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Default task.
|
|
|
|
// Does a normal build.
|
|
|
|
grunt.registerTask("default", ["build"]);
|
2013-02-14 22:21:35 +04:00
|
|
|
};
|