Permalink
Browse files

Add release task to grunt.js, using custom zip task. Currently breaks…

… due to a bug in zipstream (#5).
  • Loading branch information...
1 parent aca2e93 commit 9feeed5c8fddaba106b1527ccc2625a71cc9056a @jzaefferer jzaefferer committed Feb 29, 2012
Showing with 73 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. BIN demo/captcha/images/button.psd
  3. +60 −1 grunt.js
  4. +1 −1 jquery.validate.js
  5. +11 −4 package.json
View
@@ -6,3 +6,4 @@ docs
*.diff
*.patch
.DS_Store
+node_modules
Deleted file not rendered
View
@@ -8,11 +8,19 @@ config.init({
'* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
+ concat: {
+ 'dist/jquery.validate.js': ['<banner>', '<file_strip_banner:jquery.validate.js>'],
+ 'dist/additional-methods.js': ['<banner>', '<file_strip_banner:additional-methods.js>']
+ },
+ min: {
+ 'dist/jquery.validate.min.js': ['<banner>', 'dist/jquery.validate.js'],
+ 'dist/additional-methods.min.js': ['<banner>', 'dist/additional-methods.js']
+ },
qunit: {
files: ['test/index.html']
},
lint: {
- files: ['grunt.js', 'jquery.validate.js']
+ files: ['jquery.validate.js']
},
jshint: {
options: {
@@ -35,4 +43,55 @@ config.init({
}
});
+task.registerTask('zip', 'Create a zip file for release', function() {
+ var folder = config('pkg').name + '-' + config('pkg').version;
+ var target = 'dist/' + folder + '.zip';
+ log.writeln('Zipping into ' + target);
+
+ var done = this.async();
+
+ var zipstream = require('zipstream');
+ var fs = require('fs');
+
+ var out = fs.createWriteStream(target);
+ var zip = zipstream.createZip({ level: 1 });
+
+ zip.pipe(out);
+
+ function addFile() {
+ if (!files.length) {
+ zip.finalize(function(written) {
+ log.writeln(written + ' total bytes written');
+ done();
+ });
+ return;
+ }
+ var file = files.shift();
+ log.writeln('Zipping ' + file.file);
+ zip.addFile(fs.createReadStream(file.file), { name: folder + '/' + file.name }, addFile);
+ }
+
+ // TODO use the concat results instead of copying the original source files
+ // or don't use grunt's banner support, replace @VERSION instead
+ var files = [{
+ file: 'dist/additional-methods.min.js',
+ name: 'additional-methods.min.js'
+ },
+ {
+ file: 'dist/jquery.validate.min.js',
+ name: 'jquery.validate.min.js'
+ }];
+ file.recurse('.', function(name) {
+ if (/^(:?node_modules|dist|\.|build)/.test(name)) {
+ return;
+ }
+ files.push({
+ file: name,
+ name: name
+ });
+ });
+ addFile();
+});
+
task.registerTask('default', 'lint qunit');
+task.registerTask('release', 'default concat min zip');
View
@@ -4,7 +4,7 @@
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
- * Copyright (c) 2006 - 2011 Jörn Zaefferer
+ * Copyright (c) 2012 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
View
@@ -1,8 +1,8 @@
{
- "name": "validation",
+ "name": "jquery-validation",
"title": "jQuery Validation Plugin",
"description": "Form validation made easy",
- "version": "1.9.0",
+ "version": "1.10.0pre",
"homepage": "https://github.com/jzaefferer/jquery-validation",
"author": {
"name": "Jörn Zaefferer",
@@ -19,10 +19,17 @@
"licenses": [
{
"type": "MIT",
- "url": "https://github.com/jzaefferer/jquery-validation/blob/master/LICENSE-MIT"
+ "url": "http://www.opensource.org/licenses/MIT"
+ },
+ {
+ "type": "GPL",
+ "url": "http://www.opensource.org/licenses/GPL-2.0"
}
],
"dependencies": {},
- "devDependencies": {},
+ "devDependencies": {
+ "grunt": "0.2.x",
+ "zipstream": "0.2.x"
+ },
"keywords": []
}

0 comments on commit 9feeed5

Please sign in to comment.