1 module.exports = function( Release ) {
5 shell = require( "shelljs" ),
7 // Windows needs the .cmd version but will find the non-.cmd
8 // On Windows, ensure the HOME environment variable is set
9 gruntCmd = process.platform === "win32" ? "grunt.cmd" : "grunt",
11 devFile = "dist/jquery.js",
12 minFile = "dist/jquery.min.js",
13 mapFile = "dist/jquery.min.map",
15 cdnFolder = "dist/cdn",
18 "jquery-VER.js": devFile,
19 "jquery-VER.min.js": minFile,
20 "jquery-VER.min.map": mapFile //,
21 // Disable these until 2.0 defeats 1.9 as the ONE TRUE JQUERY
22 // "jquery.js": devFile,
23 // "jquery.min.js": minFile,
24 // "jquery.min.map": mapFile,
25 // "jquery-latest.js": devFile,
26 // "jquery-latest.min.js": minFile,
27 // "jquery-latest.min.map": mapFile
31 "jquery.js", "jquery.min.js", "jquery.min.map"
35 "jquery-VER.js", "jquery-VER.min.js", "jquery-VER.min.map"
38 _complete = Release.complete;
41 * Generates copies for the CDNs
43 function makeReleaseCopies() {
44 shell.mkdir( "-p", cdnFolder );
46 Object.keys( releaseFiles ).forEach(function( key ) {
48 builtFile = releaseFiles[ key ],
49 unpathedFile = key.replace( /VER/g, Release.newVersion ),
50 releaseFile = cdnFolder + "/" + unpathedFile;
52 // Beta releases don't update the jquery-latest etc. copies
53 if ( !Release.preRelease || key.indexOf( "VER" ) >= 0 ) {
55 if ( /\.map$/.test( releaseFile ) ) {
56 // Map files need to reference the new uncompressed name;
57 // assume that all files reside in the same directory.
58 // "file":"jquery.min.js","sources":["jquery.js"]
59 text = fs.readFileSync( builtFile, "utf8" )
60 .replace( /"file":"([^"]+)","sources":\["([^"]+)"\]/,
61 "\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js" ) +
62 "\",\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]" );
63 fs.writeFileSync( releaseFile, text );
64 } else if ( /\.min\.js$/.test( releaseFile ) ) {
65 // Remove the source map comment; it causes way too many problems.
66 // Keep the map file in case DevTools allow manual association.
67 text = fs.readFileSync( builtFile, "utf8" )
68 .replace( /\/\/# sourceMappingURL=\S+/, "" );
69 fs.writeFileSync( releaseFile, text );
70 } else if ( builtFile !== releaseFile ) {
71 shell.cp( "-f", builtFile, releaseFile );
77 function buildGoogleCDN() {
78 makeArchive( "googlecdn", googleFilesCDN );
81 function buildMicrosoftCDN() {
82 makeArchive( "mscdn", msFilesCDN );
85 function makeArchive( cdn, files ) {
86 if ( Release.preRelease ) {
87 console.log( "Skipping archive creation for " + cdn + "; this is a beta release." );
91 console.log( "Creating production archive for " + cdn );
93 var archiver = require( "archiver" )( "zip" ),
94 md5file = cdnFolder + "/" + cdn + "-md5.txt",
95 output = fs.createWriteStream( cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip" );
97 output.on( "error", function( err ) {
101 archiver.pipe( output );
103 files = files.map(function( item ) {
104 return cdnFolder + "/" + item.replace( /VER/g, Release.newVersion );
107 shell.exec( "md5sum", files, function( code, stdout ) {
108 fs.writeFileSync( md5file, stdout );
109 files.push( md5file );
111 files.forEach(function( file ) {
112 archiver.append( fs.createReadStream( file ), { name: file } );
121 issueTracker: "trac",
122 contributorReportId: 508,
124 * Generates any release artifacts that should be included in the release.
125 * The callback must be invoked with an array of files that should be
126 * committed before creating the tag.
127 * @param {Function} callback
129 generateArtifacts: function( callback ) {
130 if ( Release.exec( gruntCmd ).code !== 0 ) {
131 Release.abort("Grunt command failed");
134 callback([ "dist/jquery.js", "dist/jquery.min.js", "dist/jquery.min.map" ]);
139 complete: function() {
140 // Build CDN archives async
146 * Our trac milestones are different than the new version
149 * // For Release.newVersion equal to 2.1.0 or 1.11.0
150 * Release._tracMilestone();
153 * // For Release.newVersion equal to 2.1.1 or 1.11.1
154 * Release._tracMilestone();
157 tracMilestone: function() {
159 m = Release.newVersion.split( "." ),
162 patch = m[2] | 0 ? "." + m[2] : "",
163 version = major + "." + minor + patch;
165 otherVersion = "2." + ( minor - 10 ) + patch;
166 return version + "/" + otherVersion;
168 otherVersion = "1." + ( minor + 10 ) + patch;
169 return otherVersion + "/" + version;