aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorRafael Xavier de Souza <rxaviers@gmail.com>2013-06-05 09:38:08 -0300
committerRafael Xavier de Souza <rxaviers@gmail.com>2013-06-26 12:40:57 -0300
commita8897d4c728dc3a1ac481ed4b9234745097e146a (patch)
tree893ee0bcc1b114bd5501bd1af9e65d98a3b67ddf /build
parente591a7a9af123862fbef9d55c54351f6f995b7a7 (diff)
downloadjquery-ui-a8897d4c728dc3a1ac481ed4b9234745097e146a.tar.gz
jquery-ui-a8897d4c728dc3a1ac481ed4b9234745097e146a.zip
Release: Use downloadBuilder to build pre/cdn packages instead of our grunt tasks
Diffstat (limited to 'build')
-rw-r--r--build/release/release.js196
-rw-r--r--build/tasks/build.js79
2 files changed, 177 insertions, 98 deletions
diff --git a/build/release/release.js b/build/release/release.js
index 3cbee64b7..df281af2d 100644
--- a/build/release/release.js
+++ b/build/release/release.js
@@ -8,8 +8,9 @@
"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 +26,8 @@ walk([
confirm,
section( "building release" ),
- buildRelease,
+ buildReleaseBranch,
+ buildPackage,
section( "pushing tag" ),
confirmReview,
@@ -66,13 +68,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();
}
@@ -135,9 +130,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 +152,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 +163,175 @@ 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 );
+ },
+ bundleFiles = [],
+ 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." );
@@ -419,7 +576,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", function( error ) {
if ( error ) {
console.log( error );
return process.exit( 1 );
@@ -427,6 +584,7 @@ function _bootstrap( fn ) {
require( "shelljs/global" );
require( "colors" );
+ downloadBuilder = require( "download.jqueryui.com" );
fn();
});
diff --git a/build/tasks/build.js b/build/tasks/build.js
index ca36ff998..507bc6e11 100644
--- a/build/tasks/build.js
+++ b/build/tasks/build.js
@@ -132,85 +132,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" );
});