3 shell = require( "shelljs" ),
5 cdnFolder = "dist/cdn",
7 devFile = "dist/jquery.js",
8 minFile = "dist/jquery.min.js",
9 mapFile = "dist/jquery.min.map",
12 "jquery-VER.js": devFile,
13 "jquery-VER.min.js": minFile,
14 "jquery-VER.min.map": mapFile
18 "jquery.js", "jquery.min.js", "jquery.min.map"
22 "jquery-VER.js", "jquery-VER.min.js", "jquery-VER.min.map"
26 * Generates copies for the CDNs
28 function makeReleaseCopies( Release ) {
29 shell.mkdir( "-p", cdnFolder );
31 Object.keys( releaseFiles ).forEach(function( key ) {
33 builtFile = releaseFiles[ key ],
34 unpathedFile = key.replace( /VER/g, Release.newVersion ),
35 releaseFile = cdnFolder + "/" + unpathedFile;
37 if ( /\.map$/.test( releaseFile ) ) {
38 // Map files need to reference the new uncompressed name;
39 // assume that all files reside in the same directory.
40 // "file":"jquery.min.js","sources":["jquery.js"]
41 text = fs.readFileSync( builtFile, "utf8" )
42 .replace( /"file":"([^"]+)","sources":\["([^"]+)"\]/,
43 "\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js" ) +
44 "\",\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]" );
45 fs.writeFileSync( releaseFile, text );
46 } else if ( /\.min\.js$/.test( releaseFile ) ) {
47 // Remove the source map comment; it causes way too many problems.
48 // Keep the map file in case DevTools allow manual association.
49 text = fs.readFileSync( builtFile, "utf8" )
50 .replace( /\/\/# sourceMappingURL=\S+/, "" );
51 fs.writeFileSync( releaseFile, text );
52 } else if ( builtFile !== releaseFile ) {
53 shell.cp( "-f", builtFile, releaseFile );
58 function makeArchive( Release, cdn, files ) {
59 if ( Release.preRelease ) {
60 console.log( "Skipping archive creation for " + cdn + "; this is a beta release." );
64 console.log( "Creating production archive for " + cdn );
66 var archiver = require( "archiver" )( "zip" ),
67 md5file = cdnFolder + "/" + cdn + "-md5.txt",
68 output = fs.createWriteStream(
69 cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip"
72 output.on( "error", function( err ) {
76 archiver.pipe( output );
78 files = files.map(function( item ) {
79 return cdnFolder + "/" + item.replace( /VER/g, Release.newVersion );
82 shell.exec( "md5sum", files, function( code, stdout ) {
83 fs.writeFileSync( md5file, stdout );
84 files.push( md5file );
86 files.forEach(function( file ) {
87 archiver.append( fs.createReadStream( file ), { name: file } );
94 function buildGoogleCDN( Release ) {
95 makeArchive( Release, "googlecdn", googleFilesCDN );
98 function buildMicrosoftCDN( Release ) {
99 makeArchive( Release, "mscdn", msFilesCDN );
103 makeReleaseCopies: makeReleaseCopies,
104 buildGoogleCDN: buildGoogleCDN,
105 buildMicrosoftCDN: buildMicrosoftCDN