Skip to content

Commit 6c738d9

Browse files
committed
Release: Update for 1.12 release, add test script
Fixes jquery/download.jqueryui.com#282
1 parent 3fb25df commit 6c738d9

File tree

2 files changed

+82
-15
lines changed

2 files changed

+82
-15
lines changed

build/release-test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var shell = require( "shelljs" );
2+
var Release = {
3+
define: function( props ) {
4+
for ( var key in props ) {
5+
Release[ key ] = props[ key ];
6+
}
7+
},
8+
exec: function( _options, errorMessage ) {
9+
var result,
10+
command = _options.command || _options,
11+
options = {};
12+
13+
if ( _options.silent ) {
14+
options.silent = true;
15+
}
16+
17+
errorMessage = errorMessage || "Error executing command: " + command;
18+
19+
result = shell.exec( command, options );
20+
if ( result.code !== 0 ) {
21+
Release.abort( errorMessage );
22+
}
23+
24+
return result.output;
25+
},
26+
abort: function() {
27+
console.error.apply( console, arguments );
28+
process.exit( 1 );
29+
},
30+
newVersion: require( "../package" ).version
31+
};
32+
33+
var script = require( "./release" );
34+
script( Release );
35+
36+
// Ignores actual version installed, should be good enough for a test
37+
if ( shell.exec( "npm ls --depth 0 | grep download.jqueryui.com" ).code === 1 ) {
38+
shell.exec( "npm install " + script.dependencies.join( " " ) );
39+
}
40+
41+
// If AUTHORS.txt is outdated, this will update it
42+
// Very annoying during an actual release
43+
shell.exec( "grunt update-authors" );
44+
45+
Release.generateArtifacts( function() {
46+
console.log( "Done generating artifacts, verify output, should be in dist/cdn" );
47+
} );

build/release.js

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = function( Release ) {
22

3+
var crypto = require( "crypto" );
34
var shell = require( "shelljs" ),
45
path = require( "path" ),
56
fs = require( "fs" );
@@ -34,23 +35,41 @@ function replaceAtVersion() {
3435
return matches;
3536
}
3637

38+
function addManifest( packager ) {
39+
var output = packager.builtFiles;
40+
output.MANIFEST = Object.keys( output ).sort( function( a, b ) {
41+
return a.localeCompare( b );
42+
} ).map( function( filepath ) {
43+
var md5 = crypto.createHash( "md5" );
44+
md5.update( output[ filepath ] );
45+
return filepath + " " + md5.digest( "hex" );
46+
} ).join( "\n" );
47+
}
48+
3749
function buildCDNPackage( callback ) {
3850
console.log( "Building CDN package" );
39-
var downloadBuilder = require( "download.jqueryui.com" ),
40-
jqueryUi = new downloadBuilder.JqueryUi( path.resolve( "." ) ),
41-
builder = new downloadBuilder.Builder( jqueryUi, ":all:" ),
42-
packer = new downloadBuilder.ThemesPacker( builder, {
43-
includeJs: true
51+
var JqueryUi = require( "download.jqueryui.com/lib/jquery-ui" );
52+
var Package = require( "download.jqueryui.com/lib/package-1-12-themes" );
53+
var Packager = require( "node-packager" );
54+
var jqueryUi = new JqueryUi( path.resolve( "." ) );
55+
var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip" );
56+
var packager = new Packager( jqueryUi.files().cache, Package, {
57+
components: jqueryUi.components().map( function( component ) {
58+
return component.name;
4459
} ),
45-
target = "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip";
46-
47-
// Zip dir structure must be flat, override default base folder
48-
packer.basedir = "";
49-
packer.zipTo( target, function( error ) {
50-
if ( error ) {
51-
Release.abort( "Failed to zip CDN package", error );
52-
}
53-
callback();
60+
jqueryUi: jqueryUi,
61+
themeVars: null
62+
} );
63+
packager.ready.then( function() {
64+
addManifest( packager );
65+
packager.toZip( target, {
66+
basedir: ""
67+
}, function( error ) {
68+
if ( error ) {
69+
Release.abort( "Failed to zip CDN package", error );
70+
}
71+
callback();
72+
} );
5473
} );
5574
}
5675

@@ -91,6 +110,7 @@ Release.define( {
91110
};
92111

93112
module.exports.dependencies = [
94-
"download.jqueryui.com@2.1.1",
113+
"download.jqueryui.com@2.1.2",
114+
"node-packager@0.0.6",
95115
"shelljs@0.2.6"
96116
];

0 commit comments

Comments
 (0)