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-04-09 22:44:08 +04:00
|
|
|
grunt.loadNpmTasks('grunt-text-replace');
|
2013-02-15 22:58:57 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-04-23 04:20:07 +04:00
|
|
|
var packageJson = grunt.file.readJSON("package.json"),
|
|
|
|
distribution = "build/openseadragon/openseadragon.js",
|
2013-02-21 23:56:16 +04:00
|
|
|
minified = "build/openseadragon/openseadragon.min.js",
|
2013-04-23 04:20:07 +04:00
|
|
|
packageDirName = "openseadragon-bin-" + packageJson.version,
|
|
|
|
packageDir = "build/" + packageDirName + "/",
|
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-04-23 04:20:07 +04:00
|
|
|
pkg: packageJson,
|
2013-02-27 21:59:51 +04:00
|
|
|
clean: {
|
|
|
|
build: ["build"],
|
2013-04-24 05:16:33 +04:00
|
|
|
package: [packageDir],
|
2013-02-27 21:59:51 +04:00
|
|
|
release: {
|
2013-07-23 05:11:14 +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-05-14 07:37:23 +04:00
|
|
|
+ "//! http://openseadragon.github.io\n"
|
|
|
|
+ "//! License: http://openseadragon.github.io/license/\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-04-09 22:44:08 +04:00
|
|
|
replace: {
|
|
|
|
cleanPaths: {
|
|
|
|
src: ['build/openseadragon/*.map'],
|
|
|
|
overwrite: true,
|
|
|
|
replacements: [
|
|
|
|
{
|
|
|
|
from: /build\/openseadragon\//g,
|
|
|
|
to: ''
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
uglify: {
|
2013-03-11 22:52:30 +04:00
|
|
|
options: {
|
2013-03-25 22:22:09 +04:00
|
|
|
preserveComments: "some",
|
|
|
|
sourceMap: function (filename) {
|
|
|
|
return filename.replace(/\.js$/, '.js.map');
|
2013-03-26 23:45:22 +04:00
|
|
|
},
|
|
|
|
sourceMappingURL: function (filename) {
|
|
|
|
return filename.replace(/\.js$/, '.js.map').replace('build/openseadragon/', '');
|
|
|
|
},
|
2013-03-11 22:52:30 +04:00
|
|
|
},
|
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: {
|
2013-04-23 04:27:55 +04:00
|
|
|
archive: "build/releases/" + packageDirName + ".zip",
|
2013-04-19 09:01:15 +04:00
|
|
|
level: 9
|
2013-02-21 23:56:16 +04:00
|
|
|
},
|
|
|
|
files: [
|
2013-04-23 04:20:07 +04:00
|
|
|
{ expand: true, cwd: "build/", src: [ packageDirName + "/**" ] }
|
2013-02-21 23:56:16 +04:00
|
|
|
]
|
2013-02-15 22:58:57 +04:00
|
|
|
},
|
|
|
|
tar: {
|
2013-02-21 23:56:16 +04:00
|
|
|
options: {
|
2013-04-23 04:27:55 +04:00
|
|
|
archive: "build/releases/" + packageDirName + ".tar.gz",
|
2013-04-19 09:01:15 +04:00
|
|
|
level: 9
|
2013-02-21 23:56:16 +04:00
|
|
|
},
|
|
|
|
files: [
|
2013-04-23 04:20:07 +04:00
|
|
|
{ expand: true, cwd: "build/", src: [ packageDirName + "/**" ] }
|
2013-02-21 23:56:16 +04:00
|
|
|
]
|
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: {
|
2013-03-24 05:05:39 +04:00
|
|
|
timeout: 10000,
|
2013-02-21 23:17:05 +04:00
|
|
|
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-06-19 01:18:47 +04:00
|
|
|
jshintrc: '.jshintrc'
|
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-06-19 21:33:25 +04:00
|
|
|
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
|
2013-02-15 01:24:50 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-04-23 04:20:07 +04:00
|
|
|
// ----------
|
|
|
|
// Copy:package task.
|
|
|
|
// Creates a directory tree to be compressed into a package.
|
|
|
|
grunt.registerTask("copy:package", function() {
|
|
|
|
grunt.file.recurse("build/openseadragon", function(abspath, rootdir, subdir, filename) {
|
|
|
|
var dest = packageDir
|
|
|
|
+ (subdir ? subdir + "/" : '/')
|
|
|
|
+ filename;
|
|
|
|
grunt.file.copy(abspath, dest);
|
|
|
|
});
|
2013-04-19 10:40:27 +04:00
|
|
|
grunt.file.copy("changelog.txt", packageDir + "changelog.txt");
|
2013-05-01 09:06:42 +04:00
|
|
|
grunt.file.copy("LICENSE.txt", packageDir + "LICENSE.txt");
|
2013-04-23 04:20:07 +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-07-22 11:52:24 +04:00
|
|
|
if (subdir === 'releases') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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-04-09 22:44:08 +04:00
|
|
|
"clean:build", "jshint:beforeconcat", "git-describe", "concat", "jshint:afterconcat",
|
|
|
|
"uglify", "replace:cleanPaths", "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-04-23 04:20:07 +04:00
|
|
|
grunt.registerTask("package", ["build", "copy:package", "compress", "clean:package"]);
|
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
|
|
|
};
|