Merge branch 'master' into selectmenu

This commit is contained in:
Felix Nagel 2013-07-01 23:23:50 +02:00
commit c571f7bea9
4 changed files with 194 additions and 230 deletions

View File

@ -154,9 +154,7 @@ function createBanner( files ) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
files: {
dist: "<%= pkg.name %>-<%= pkg.version %>",
cdn: "<%= pkg.name %>-<%= pkg.version %>-cdn",
themes: "<%= pkg.name %>-themes-<%= pkg.version %>"
dist: "<%= pkg.name %>-<%= pkg.version %>"
},
compare_size: compareFiles,
concat: {
@ -197,122 +195,10 @@ grunt.initConfig({
})
},
copy: {
dist: {
src: [
"AUTHORS.txt",
"jquery-*.js",
"MIT-LICENSE.txt",
"README.md",
"Gruntfile.js",
"package.json",
"*.jquery.json",
"ui/**/*",
"ui/.jshintrc",
"demos/**/*",
"themes/**/*",
"external/**/*",
"tests/**/*"
],
renames: {
"dist/jquery-ui.js": "ui/jquery-ui.js",
"dist/jquery-ui.min.js": "ui/minified/jquery-ui.min.js",
"dist/i18n/jquery-ui-i18n.js": "ui/i18n/jquery-ui-i18n.js",
"dist/i18n/jquery-ui-i18n.min.js": "ui/minified/i18n/jquery-ui-i18n.min.js",
"dist/jquery-ui.css": "themes/base/jquery-ui.css",
"dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css"
},
dest: "dist/<%= files.dist %>"
},
dist_min: {
src: "dist/minified/**/*",
strip: /^dist/,
dest: "dist/<%= files.dist %>/ui"
},
dist_css_min: {
src: "dist/themes/base/minified/*.css",
strip: /^dist/,
dest: "dist/<%= files.dist %>"
},
dist_units_images: {
src: "themes/base/images/*",
strip: /^themes\/base\//,
dest: "dist/"
},
dist_min_images: {
src: "themes/base/images/*",
strip: /^themes\/base\//,
dest: "dist/<%= files.dist %>/themes/base/minified"
},
cdn: {
src: [
"AUTHORS.txt",
"MIT-LICENSE.txt",
"ui/*.js",
"package.json"
],
renames: {
"dist/jquery-ui.js": "jquery-ui.js",
"dist/jquery-ui.min.js": "jquery-ui.min.js",
"dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js",
"dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js"
},
dest: "dist/<%= files.cdn %>"
},
cdn_i18n: {
src: "ui/i18n/jquery.ui.datepicker-*.js",
strip: "ui/",
dest: "dist/<%= files.cdn %>"
},
cdn_i18n_min: {
src: "dist/minified/i18n/jquery.ui.datepicker-*.js",
strip: "dist/minified",
dest: "dist/<%= files.cdn %>"
},
cdn_min: {
src: "dist/minified/*.js",
strip: /^dist\/minified/,
dest: "dist/<%= files.cdn %>/ui"
},
cdn_themes: {
src: "dist/<%= files.themes %>/themes/**/*",
strip: "dist/<%= files.themes %>",
dest: "dist/<%= files.cdn %>"
},
themes: {
src: [
"AUTHORS.txt",
"MIT-LICENSE.txt",
"package.json"
],
dest: "dist/<%= files.themes %>"
}
},
zip: {
dist: {
src: "<%= files.dist %>",
dest: "<%= files.dist %>.zip"
},
cdn: {
src: "<%= files.cdn %>",
dest: "<%= files.cdn %>.zip"
},
themes: {
src: "<%= files.themes %>",
dest: "<%= files.themes %>.zip"
}
},
md5: {
dist: {
src: "dist/<%= files.dist %>",
dest: "dist/<%= files.dist %>/MANIFEST"
},
cdn: {
src: "dist/<%= files.cdn %>",
dest: "dist/<%= files.cdn %>/MANIFEST"
},
themes: {
src: "dist/<%= files.themes %>",
dest: "dist/<%= files.themes %>/MANIFEST"
}
},
qunit: {
@ -363,9 +249,8 @@ grunt.registerTask( "lint", [ "jshint", "csslint", "htmllint" ] );
grunt.registerTask( "test", [ "qunit" ] );
grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] );
grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] );
// "copy:dist_units_images" is used by unit tests
grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] );
grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist".split( " " ) );
grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes".split( " " ) );
grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_themes md5:cdn zip:cdn".split( " " ) );
};

View File

@ -4,12 +4,14 @@
// Usage:
// stable release: node release.js
// pre-release: node release.js --pre-release {version}
// test run: node release.js --remote=user/repo
// test run: node release.js --remote={repo}
// - repo: "/tmp/repo" (filesystem), "user/repo" (github), "http://mydomain/repo.git" (another domain)
"use strict";
var baseDir, repoDir, prevVersion, newVersion, nextVersion, tagTime, preRelease, repo,
var baseDir, downloadBuilder, repoDir, prevVersion, newVersion, nextVersion, tagTime, preRelease, repo,
fs = require( "fs" ),
path = require( "path" ),
rnewline = /\r?\n/,
branch = "master";
@ -25,7 +27,8 @@ walk([
confirm,
section( "building release" ),
buildRelease,
buildReleaseBranch,
buildPackage,
section( "pushing tag" ),
confirmReview,
@ -66,13 +69,6 @@ function cloneRepo() {
if ( exec( "npm install" ).code !== 0 ) {
abort( "Error installing dependencies." );
}
// We need download.jqueryui.com in order to generate themes.
// We only generate themes for stable releases.
if ( !preRelease ) {
if ( exec( "npm install download.jqueryui.com" ).code !== 0 ) {
abort( "Error installing dependencies." );
}
}
echo();
}
@ -109,8 +105,7 @@ function getVersions() {
if ( preRelease ) {
newVersion = preRelease;
// Note: prevVersion is not currently used for pre-releases. The TODO
// below about 1.10.0 applies here as well.
// Note: prevVersion is not currently used for pre-releases.
prevVersion = nextVersion = currentVersion;
} else {
newVersion = currentVersion.substr( 0, currentVersion.length - 3 );
@ -119,15 +114,14 @@ function getVersions() {
minor = parseInt( parts[ 1 ], 10 );
patch = parseInt( parts[ 2 ], 10 );
// TODO: handle 1.10.0
// Also see comment above about pre-releases
if ( patch === 0 ) {
abort( "This script is not smart enough to handle the 1.10.0 release." );
if ( minor === 0 && patch === 0 ) {
abort( "This script is not smart enough to handle major release (eg. 2.0.0)." );
} else if ( patch === 0 ) {
prevVersion = git( "for-each-ref --count=1 --sort=-authordate --format='%(refname:short)' refs/tags/" + [ major, minor - 1 ].join( "." ) + "*" ).trim();
} else {
prevVersion = [ major, minor, patch - 1 ].join( "." );
}
prevVersion = patch === 0 ?
[ major, minor - 1, 0 ].join( "." ) :
[ major, minor, patch - 1 ].join( "." );
nextVersion = [ major, minor, patch + 1 ].join( "." ) + "pre";
}
@ -135,9 +129,8 @@ function getVersions() {
echo( "After the release, the version will be " + nextVersion.cyan + "." );
}
function buildRelease() {
var pkg,
releaseTask = preRelease ? "release" : "release_cdn";
function buildReleaseBranch() {
var pkg;
echo( "Creating " + "release".cyan + " branch..." );
git( "checkout -b release", "Error creating release branch." );
@ -158,12 +151,6 @@ function buildRelease() {
}
echo();
echo( "Building release..." );
if ( exec( "grunt " + releaseTask ).code !== 0 ) {
abort( "Error building release." );
}
echo();
echo( "Committing release artifacts..." );
git( "add *.jquery.json", "Error adding manifest files to git." );
git( "commit -am 'Tagging the " + newVersion + " release.'",
@ -175,6 +162,173 @@ function buildRelease() {
tagTime = git( "log -1 --format='%ad'", "Error getting tag timestamp." ).trim();
}
function buildPackage( callback ) {
if( preRelease ) {
return buildPreReleasePackage( callback );
} else {
return buildCDNPackage( callback );
}
}
function buildPreReleasePackage( callback ) {
var build, files, jqueryUi, packer, target, targetZip;
echo( "Build pre-release Package" );
jqueryUi = new downloadBuilder.JqueryUi( path.resolve( "." ) );
build = new downloadBuilder.Builder( jqueryUi, ":all:" );
packer = new downloadBuilder.Packer( build, null, {
addTests: true,
bundleSuffix: "",
skipDocs: true,
skipTheme: true
});
target = "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version;
targetZip = target + ".zip";
return walk([
function( callback ) {
echo( "Building release files" );
packer.pack(function( error, _files ) {
if( error ) {
abort( error.stack );
}
files = _files.map(function( file ) {
// Strip first path
file.path = file.path.replace( /^[^\/]*\//, "" );
return file;
}).filter(function( file ) {
// Filter development-bundle content only
return (/^development-bundle/).test( file.path );
}).map(function( file ) {
// Strip development-bundle
file.path = file.path.replace( /^development-bundle\//, "" );
return file;
});
return callback();
});
},
function() {
downloadBuilder.util.createZip( files, targetZip, function( error ) {
if ( error ) {
abort( error.stack );
}
echo( "Built zip package at " + path.relative( "../..", targetZip ).cyan );
return callback();
});
}
]);
}
function buildCDNPackage( callback ) {
var build, output, target, targetZip,
add = function( file ) {
output.push( file );
},
jqueryUi = new downloadBuilder.JqueryUi( path.resolve( "." ) ),
themeGallery = downloadBuilder.themeGallery( jqueryUi );
echo( "Build CDN Package" );
build = new downloadBuilder.Builder( jqueryUi, ":all:" );
output = [];
target = "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn";
targetZip = target + ".zip";
[ "AUTHORS.txt", "MIT-LICENSE.txt", "package.json" ].map(function( name ) {
return build.get( name );
}).forEach( add );
// "ui/*.js"
build.componentFiles.filter(function( file ) {
return (/^ui\//).test( file.path );
}).forEach( add );
// "ui/*.min.js"
build.componentMinFiles.filter(function( file ) {
return (/^ui\//).test( file.path );
}).forEach( add );
// "i18n/*.js"
build.i18nFiles.rename( /^ui\//, "" ).forEach( add );
build.i18nMinFiles.rename( /^ui\//, "" ).forEach( add );
build.bundleI18n.into( "i18n/" ).forEach( add );
build.bundleI18nMin.into( "i18n/" ).forEach( add );
build.bundleJs.forEach( add );
build.bundleJsMin.forEach( add );
walk( themeGallery.map(function( theme ) {
return function( callback ) {
var themeCssOnlyRe, themeDirRe,
folderName = theme.folderName(),
packer = new downloadBuilder.Packer( build, theme, {
skipDocs: true
});
// TODO improve code by using custom packer instead of download packer (Packer)
themeCssOnlyRe = new RegExp( "development-bundle/themes/" + folderName + "/jquery.ui.theme.css" );
themeDirRe = new RegExp( "css/" + folderName );
packer.pack(function( error, files ) {
if ( error ) {
abort( error.stack );
}
// Add theme files.
files
// Pick only theme files we need on the bundle.
.filter(function( file ) {
if ( themeCssOnlyRe.test( file.path ) || themeDirRe.test( file.path ) ) {
return true;
}
return false;
})
// Convert paths the way bundle needs
.map(function( file ) {
file.path = file.path
// Remove initial package name eg. "jquery-ui-1.10.0.custom"
.split( "/" ).slice( 1 ).join( "/" )
.replace( /development-bundle\/themes/, "css" )
.replace( /css/, "themes" )
// Make jquery-ui-1.10.0.custom.css into jquery-ui.css, or jquery-ui-1.10.0.custom.min.css into jquery-ui.min.css
.replace( /jquery-ui-.*?(\.min)*\.css/, "jquery-ui$1.css" );
return file;
}).forEach( add );
return callback();
});
};
}).concat([function() {
var crypto = require( "crypto" );
// Create MD5 manifest
output.push({
path: "MANIFEST",
data: output.sort(function( a, b ) {
return a.path.localeCompare( b.path );
}).map(function( file ) {
var md5 = crypto.createHash( "md5" );
md5.update( file.data );
return file.path + " " + md5.digest( "hex" );
}).join( "\n" )
});
downloadBuilder.util.createZip( output, targetZip, function( error ) {
if ( error ) {
abort( error.stack );
}
echo( "Built zip CDN package at " + path.relative( "../..", targetZip ).cyan );
return callback();
});
}]));
}
function pushRelease() {
echo( "Pushing release to GitHub..." );
git( "push --tags", "Error pushing tags to GitHub." );
@ -358,7 +512,11 @@ function writePackage( pkg ) {
function bootstrap( fn ) {
getRemote(function( remote ) {
repo = "git@github.com:" + remote + ".git";
if ( (/:/).test( remote ) || fs.existsSync( remote ) ) {
repo = remote;
} else {
repo = "git@github.com:" + remote + ".git";
}
_bootstrap( fn );
});
}
@ -419,7 +577,7 @@ function _bootstrap( fn ) {
fs.mkdirSync( baseDir );
console.log( "Installing dependencies..." );
require( "child_process" ).exec( "npm install shelljs colors", function( error ) {
require( "child_process" ).exec( "npm install shelljs colors download.jqueryui.com@1.10.3-4", function( error ) {
if ( error ) {
console.log( error );
return process.exit( 1 );
@ -427,6 +585,7 @@ function _bootstrap( fn ) {
require( "shelljs/global" );
require( "colors" );
downloadBuilder = require( "download.jqueryui.com" );
fn();
});

View File

@ -2,8 +2,7 @@ module.exports = function( grunt ) {
"use strict";
var path = require( "path" ),
fs = require( "fs" );
var fs = require( "fs" );
function expandFiles( files ) {
return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).filter(function(filepath) {
@ -132,85 +131,6 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @
}
});
grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
var done = this.async(),
dest = this.data.dest;
grunt.util.spawn({
cmd: "zip",
args: [ "-r", dest, this.data.src ],
opts: {
cwd: "dist"
}
}, function( err ) {
if ( err ) {
grunt.log.error( err );
done();
return;
}
grunt.log.writeln( "Zipped " + dest );
done();
});
});
grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() {
// remove dest file before creating it, to make sure itself is not included
if ( fs.existsSync( this.data.dest ) ) {
fs.unlinkSync( this.data.dest );
}
var crypto = require( "crypto" ),
dir = this.filesSrc + "/",
hashes = [];
expandFiles( dir + "**/*" ).forEach(function( fileName ) {
var hash = crypto.createHash( "md5" );
hash.update( grunt.file.read( fileName, "ascii" ) );
hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) );
});
grunt.file.write( this.data.dest, hashes.join( "\n" ) + "\n" );
grunt.log.writeln( "Wrote " + this.data.dest + " with " + hashes.length + " hashes" );
});
grunt.registerTask( "generate_themes", function() {
var download, done,
distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ),
target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/";
try {
require.resolve( "download.jqueryui.com" );
} catch( error ) {
throw new Error( "You need to manually install download.jqueryui.com for this task to work" );
}
download = require( "download.jqueryui.com" )({
config: {
"jqueryUi": {
"stable": { "path": path.resolve( __dirname + "/../../" + distFolder ) }
},
"jquery": "skip"
}
});
done = this.async();
download.buildThemesBundle(function( error, files ) {
if ( error ) {
grunt.log.error( error );
return done( false );
}
done(
files.every(function( file ) {
try {
grunt.file.write( target + file.path, file.data );
} catch( err ) {
grunt.log.error( err );
return false;
}
return true;
}) && grunt.log.writeln( "Generated at " + target )
);
});
});
grunt.registerTask( "clean", function() {
require( "rimraf" ).sync( "dist" );
});

View File

@ -2,7 +2,7 @@
jQuery(function($){
$.datepicker.regional['pt'] = {
closeText: 'Fechar',
prevText: '&#x3C;Anterior',
prevText: 'Anterior',
nextText: 'Seguinte',
currentText: 'Hoje',
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',