openseadragon/Gruntfile.js

214 lines
6.8 KiB
JavaScript
Raw Normal View History

module.exports = function(grunt) {
// ----------
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");
grunt.loadNpmTasks("grunt-contrib-clean");
2013-03-21 21:26:03 +04:00
grunt.loadNpmTasks("grunt-git-describe");
// ----------
var packageJson = grunt.file.readJSON("package.json"),
distribution = "build/openseadragon/openseadragon.js",
minified = "build/openseadragon/openseadragon.min.js",
packageDirName = "openseadragon-bin-" + packageJson.version,
packageDir = "build/" + packageDirName + "/",
releaseRoot = "../site-build/built-openseadragon/",
sources = [
"src/openseadragon.js",
"src/fullscreen.js",
"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"
];
// ----------
// Project configuration.
grunt.initConfig({
pkg: packageJson,
clean: {
build: ["build"],
2013-04-24 05:16:33 +04:00
package: [packageDir],
release: {
src: [releaseRoot + '*', '!' + releaseRoot + 'releases'],
options: {
force: true
}
}
},
concat: {
options: {
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"
+ "//! License: http://openseadragon.github.io/license/\n"
2013-04-08 21:28:56 +04:00
+ "//! http://openseadragon.github.io\n\n",
process: true
},
dist: {
2013-02-15 00:02:17 +04:00
src: [ "<banner>" ].concat(sources),
dest: distribution
}
},
uglify: {
options: {
preserveComments: "some"
},
openseadragon: {
src: [ distribution ],
dest: minified
}
},
compress: {
zip: {
options: {
archive: "build/releases/" + packageDirName + ".zip",
level: 9
},
files: [
{ expand: true, cwd: "build/", src: [ packageDirName + "/**" ] }
]
},
tar: {
options: {
archive: "build/releases/" + packageDirName + ".tar.gz",
level: 9
},
files: [
{ expand: true, cwd: "build/", src: [ packageDirName + "/**" ] }
]
}
},
qunit: {
2013-02-21 23:17:05 +04:00
all: {
options: {
urls: [ "http://localhost:8000/test/test.html" ]
}
}
},
connect: {
2013-02-21 23:17:05 +04:00
server: {
options: {
port: 8000,
base: "."
}
}
},
watch: {
files: [ "Gruntfile.js", "src/*.js", "images/*" ],
tasks: "build"
},
jshint: {
options: {
browser: true,
eqeqeq: false,
loopfunc: false,
globals: {
OpenSeadragon: true
}
},
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
}
}
});
// ----------
// Copy:build task.
// Copies the image files into the appropriate location in the build folder.
grunt.registerTask("copy:build", function() {
grunt.file.recurse("images", function(abspath, rootdir, subdir, filename) {
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
});
2013-03-25 20:51:58 +04:00
grunt.file.copy("changelog.txt", "build/changelog.txt");
});
// ----------
// 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);
});
grunt.file.copy("changelog.txt", packageDir + "changelog.txt");
grunt.file.copy("LICENSE.txt", packageDir + "LICENSE.txt");
});
// ----------
// Copy:release task.
// Copies the contents of the build folder into the release folder.
grunt.registerTask("copy:release", function() {
grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) {
var dest = releaseRoot
+ (subdir ? subdir + "/" : '/')
+ filename;
grunt.file.copy(abspath, dest);
});
});
// ----------
// 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"
]);
// ----------
// Test task.
// Builds and runs unit tests.
grunt.registerTask("test", ["build", "connect", "qunit"]);
// ----------
// Package task.
// Builds and creates the .zip and .tar.gz files.
grunt.registerTask("package", ["build", "copy:package", "compress", "clean:package"]);
2013-02-20 07:53:54 +04:00
// ----------
// Publish task.
// Cleans the built files out of the release folder and copies newly built ones over.
grunt.registerTask("publish", ["package", "clean:release", "copy:release"]);
// ----------
// Default task.
// Does a normal build.
grunt.registerTask("default", ["build"]);
};