mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Added "grunt publish" command for copying to site-build
This commit is contained in:
parent
65cc3f55e9
commit
d2b9257bc4
49
Gruntfile.js
49
Gruntfile.js
@ -7,6 +7,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.loadNpmTasks("grunt-contrib-qunit");
|
grunt.loadNpmTasks("grunt-contrib-qunit");
|
||||||
grunt.loadNpmTasks("grunt-contrib-connect");
|
grunt.loadNpmTasks("grunt-contrib-connect");
|
||||||
grunt.loadNpmTasks("grunt-contrib-watch");
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
||||||
|
grunt.loadNpmTasks("grunt-contrib-clean");
|
||||||
|
|
||||||
var distribution = "build/openseadragon/openseadragon.js",
|
var distribution = "build/openseadragon/openseadragon.js",
|
||||||
minified = "build/openseadragon/openseadragon.min.js",
|
minified = "build/openseadragon/openseadragon.min.js",
|
||||||
@ -43,6 +44,19 @@ module.exports = function(grunt) {
|
|||||||
// Project configuration.
|
// Project configuration.
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
pkg: grunt.file.readJSON("package.json"),
|
pkg: grunt.file.readJSON("package.json"),
|
||||||
|
clean: {
|
||||||
|
build: ["build"],
|
||||||
|
release: {
|
||||||
|
src: [
|
||||||
|
"../site-build/openseadragon",
|
||||||
|
"../site-build/openseadragon.zip",
|
||||||
|
"../site-build/openseadragon.tar"
|
||||||
|
],
|
||||||
|
options: {
|
||||||
|
force: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
concat: {
|
concat: {
|
||||||
options: {
|
options: {
|
||||||
banner: "/**\n * @version <%= pkg.name %> <%= pkg.version %>\n */\n\n"
|
banner: "/**\n * @version <%= pkg.name %> <%= pkg.version %>\n */\n\n"
|
||||||
@ -93,7 +107,7 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
files: [ "grunt.js", "src/*.js" ],
|
files: [ "grunt.js", "src/*.js" ],
|
||||||
tasks: "default"
|
tasks: "build"
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
options: {
|
options: {
|
||||||
@ -109,20 +123,41 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Copy task.
|
// Copy:build task.
|
||||||
grunt.registerTask("copy", function() {
|
// 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.recurse("images", function(abspath, rootdir, subdir, filename) {
|
||||||
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
|
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default task.
|
// Copy:release task.
|
||||||
grunt.registerTask("default", ["jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy"]);
|
// Copies the contents of the build folder into ../site-build.
|
||||||
|
grunt.registerTask("copy:release", function() {
|
||||||
|
grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) {
|
||||||
|
grunt.file.copy(abspath, "../site-build/" + (subdir || "") + filename);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Build task.
|
||||||
|
// Cleans out the build folder and builds the code and images into it, checking lint.
|
||||||
|
grunt.registerTask("build", [
|
||||||
|
"clean:build", "jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy:build"
|
||||||
|
]);
|
||||||
|
|
||||||
// Test task.
|
// Test task.
|
||||||
grunt.registerTask("test", ["default", "connect", "qunit"]);
|
// Builds and runs unit tests.
|
||||||
|
grunt.registerTask("test", ["build", "connect", "qunit"]);
|
||||||
|
|
||||||
// Package task.
|
// Package task.
|
||||||
grunt.registerTask("package", ["default", "compress"]);
|
// Builds and creates the .zip and .tar files.
|
||||||
|
grunt.registerTask("package", ["build", "compress"]);
|
||||||
|
|
||||||
|
// Publish task.
|
||||||
|
// Cleans the built files out of ../site-build and copies newly built ones over.
|
||||||
|
grunt.registerTask("publish", ["package", "clean:release", "copy:release"]);
|
||||||
|
|
||||||
|
// Default task.
|
||||||
|
// Does a normal build.
|
||||||
|
grunt.registerTask("default", ["build"]);
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,14 @@ If you want to build tar and zip files for distribution (they will also appear i
|
|||||||
|
|
||||||
grunt package
|
grunt package
|
||||||
|
|
||||||
|
Note that the `build` folder is masked with .gitignore; it's just for your local use, and won't be checked in to the repository.
|
||||||
|
|
||||||
|
You can also publish the built version to the site-build repository. This assumes you have cloned it next to this repository. The command is:
|
||||||
|
|
||||||
|
grunt publish
|
||||||
|
|
||||||
|
... which will delete the existing openseadragon folder, along with the .zip and .tar files, out of the site-build folder and replace them with newly built ones from the source in this repository; you'll then need to commit the changes to site-build.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Our tests are based on [QUnit](http://qunitjs.com/) and [PhantomJS](http://phantomjs.org/); they're both installed when you run `npm install`. At the moment we don't have much in the way of tests, but we're working to fix that. To run on the command line:
|
Our tests are based on [QUnit](http://qunitjs.com/) and [PhantomJS](http://phantomjs.org/); they're both installed when you run `npm install`. At the moment we don't have much in the way of tests, but we're working to fix that. To run on the command line:
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"grunt-contrib-uglify": "~0.1.1",
|
"grunt-contrib-uglify": "~0.1.1",
|
||||||
"grunt-contrib-qunit": "~0.1.1",
|
"grunt-contrib-qunit": "~0.1.1",
|
||||||
"grunt-contrib-connect": "~0.1.2",
|
"grunt-contrib-connect": "~0.1.2",
|
||||||
"grunt-contrib-watch": "~0.2.0"
|
"grunt-contrib-watch": "~0.2.0",
|
||||||
|
"grunt-contrib-clean": "~0.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test"
|
"test": "grunt test"
|
||||||
|
Loading…
Reference in New Issue
Block a user