From: Jörn Zaefferer Date: Mon, 2 Nov 2015 15:41:25 +0000 (+0100) Subject: Release: Update for 1.12 release, add test script X-Git-Tag: 1.12.0-beta.1~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6c738d961d9918f75a3043a49ab21ac79bca45ae;p=jquery-ui.git Release: Update for 1.12 release, add test script Fixes jquery/download.jqueryui.com#282 --- diff --git a/build/release-test.js b/build/release-test.js new file mode 100644 index 000000000..be5227a43 --- /dev/null +++ b/build/release-test.js @@ -0,0 +1,47 @@ +var shell = require( "shelljs" ); +var Release = { + define: function( props ) { + for ( var key in props ) { + Release[ key ] = props[ key ]; + } + }, + exec: function( _options, errorMessage ) { + var result, + command = _options.command || _options, + options = {}; + + if ( _options.silent ) { + options.silent = true; + } + + errorMessage = errorMessage || "Error executing command: " + command; + + result = shell.exec( command, options ); + if ( result.code !== 0 ) { + Release.abort( errorMessage ); + } + + return result.output; + }, + abort: function() { + console.error.apply( console, arguments ); + process.exit( 1 ); + }, + newVersion: require( "../package" ).version +}; + +var script = require( "./release" ); +script( Release ); + +// Ignores actual version installed, should be good enough for a test +if ( shell.exec( "npm ls --depth 0 | grep download.jqueryui.com" ).code === 1 ) { + shell.exec( "npm install " + script.dependencies.join( " " ) ); +} + +// If AUTHORS.txt is outdated, this will update it +// Very annoying during an actual release +shell.exec( "grunt update-authors" ); + +Release.generateArtifacts( function() { + console.log( "Done generating artifacts, verify output, should be in dist/cdn" ); +} ); diff --git a/build/release.js b/build/release.js index bebb89fec..b868cbebd 100644 --- a/build/release.js +++ b/build/release.js @@ -1,5 +1,6 @@ module.exports = function( Release ) { +var crypto = require( "crypto" ); var shell = require( "shelljs" ), path = require( "path" ), fs = require( "fs" ); @@ -34,23 +35,41 @@ function replaceAtVersion() { return matches; } +function addManifest( packager ) { + var output = packager.builtFiles; + output.MANIFEST = Object.keys( output ).sort( function( a, b ) { + return a.localeCompare( b ); + } ).map( function( filepath ) { + var md5 = crypto.createHash( "md5" ); + md5.update( output[ filepath ] ); + return filepath + " " + md5.digest( "hex" ); + } ).join( "\n" ); +} + function buildCDNPackage( callback ) { console.log( "Building CDN package" ); - var downloadBuilder = require( "download.jqueryui.com" ), - jqueryUi = new downloadBuilder.JqueryUi( path.resolve( "." ) ), - builder = new downloadBuilder.Builder( jqueryUi, ":all:" ), - packer = new downloadBuilder.ThemesPacker( builder, { - includeJs: true + var JqueryUi = require( "download.jqueryui.com/lib/jquery-ui" ); + var Package = require( "download.jqueryui.com/lib/package-1-12-themes" ); + var Packager = require( "node-packager" ); + var jqueryUi = new JqueryUi( path.resolve( "." ) ); + var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip" ); + var packager = new Packager( jqueryUi.files().cache, Package, { + components: jqueryUi.components().map( function( component ) { + return component.name; } ), - target = "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip"; - - // Zip dir structure must be flat, override default base folder - packer.basedir = ""; - packer.zipTo( target, function( error ) { - if ( error ) { - Release.abort( "Failed to zip CDN package", error ); - } - callback(); + jqueryUi: jqueryUi, + themeVars: null + } ); + packager.ready.then( function() { + addManifest( packager ); + packager.toZip( target, { + basedir: "" + }, function( error ) { + if ( error ) { + Release.abort( "Failed to zip CDN package", error ); + } + callback(); + } ); } ); } @@ -91,6 +110,7 @@ Release.define( { }; module.exports.dependencies = [ - "download.jqueryui.com@2.1.1", + "download.jqueryui.com@2.1.2", + "node-packager@0.0.6", "shelljs@0.2.6" ];