aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-12-28 20:47:33 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-12-28 21:05:01 -0500
commitc9b75df7fba7c96f38efcd60629830e76ce24863 (patch)
tree65c7398dfe83b7caf51e7d1292dcf616c5dc0f25 /build
parent861a45b8fffc2073baa9f62b0648f395f0695f3e (diff)
downloadjquery-c9b75df7fba7c96f38efcd60629830e76ce24863.tar.gz
jquery-c9b75df7fba7c96f38efcd60629830e76ce24863.zip
Add release support for map files.
Diffstat (limited to 'build')
-rw-r--r--build/release.js55
1 files changed, 45 insertions, 10 deletions
diff --git a/build/release.js b/build/release.js
index f2ace6e52..e8313c038 100644
--- a/build/release.js
+++ b/build/release.js
@@ -13,7 +13,7 @@ var fs = require("fs"),
var releaseVersion,
nextVersion,
- finalFiles,
+ CDNFiles,
isBeta,
pkg,
branch,
@@ -28,14 +28,18 @@ var releaseVersion,
devFile = "dist/jquery.js",
minFile = "dist/jquery.min.js",
+ mapFile = "dist/jquery.min.map",
releaseFiles = {
"jquery-VER.js": devFile,
"jquery-VER.min.js": minFile,
+ "jquery-VER.min.map": mapFile,
"jquery.js": devFile,
- "jquery-latest.js": devFile,
"jquery.min.js": minFile,
- "jquery-latest.min.js": minFile
+ "jquery.min.map": mapFile,
+ "jquery-latest.js": devFile,
+ "jquery-latest.min.js": minFile,
+ "jquery-latest.min.map": mapFile
};
steps(
@@ -93,6 +97,7 @@ function initialize( next ) {
nextVersion = major + "." + minor + "." + ( isBeta ? patch : +patch + 1 ) + "pre";
next();
}
+
function checkGitStatus( next ) {
git( [ "status" ], function( error, stdout, stderr ) {
var onBranch = ((stdout||"").match( /On branch (\S+)/ ) || [])[1];
@@ -108,12 +113,14 @@ function checkGitStatus( next ) {
next();
});
}
+
function tagReleaseVersion( next ) {
updatePackageVersion( releaseVersion );
git( [ "commit", "-a", "-m", "Tagging the " + releaseVersion + " release." ], function(){
git( [ "tag", releaseVersion ], next, debug);
}, debug);
}
+
function gruntBuild( next ) {
exec( gruntCmd, [], function( error, stdout ) {
if ( error ) {
@@ -123,28 +130,48 @@ function gruntBuild( next ) {
next();
}, debug);
}
+
function makeReleaseCopies( next ) {
- finalFiles = {};
+ CDNFiles = {};
Object.keys( releaseFiles ).forEach(function( key ) {
- var builtFile = releaseFiles[ key ],
+ var text,
+ builtFile = releaseFiles[ key ],
releaseFile = key.replace( /VER/g, releaseVersion );
// Beta releases don't update the jquery-latest etc. copies
if ( !isBeta || key !== releaseFile ) {
- copy( builtFile, releaseFile );
- finalFiles[ releaseFile ] = builtFile;
+
+ if ( /\.map$/.test( releaseFile ) ) {
+ // Map files need to reference the new uncompressed name;
+ // assume that all files reside in the same directory.
+ // "file":"jquery.min.js","sources":["jquery.js"]
+ text = fs.readFileSync( builtFile, "utf8" )
+ .replace( /"file":"([^"]+)","sources":\["([^"]+)"\]/,
+ "\"file\":\"" + releaseFile.replace( /\.min\.map/, ".min.js" ) +
+ "\",\"sources\":[\"" + releaseFile.replace( /\.min\.map/, ".js" ) + "\"]" );
+ console.log( "Modifying map " + builtFile + " to " + releaseFile );
+ if ( !debug ) {
+ fs.writeFileSync( releaseFile, text );
+ }
+ } else {
+ copy( builtFile, releaseFile );
+ }
+
+ CDNFiles[ releaseFile ] = builtFile;
}
});
next();
}
+
function setNextVersion( next ) {
updatePackageVersion( nextVersion );
git( [ "commit", "-a", "-m", "Updating the source version to " + nextVersion ], next, debug );
}
+
function uploadToCDN( next ) {
var cmds = [];
- Object.keys( finalFiles ).forEach(function( name ) {
+ Object.keys( CDNFiles ).forEach(function( name ) {
cmds.push(function( nxt ){
exec( "scp", [ name, scpURL ], nxt, debug || skipRemote );
});
@@ -156,6 +183,7 @@ function uploadToCDN( next ) {
steps.apply( this, cmds );
}
+
function pushToGithub( next ) {
git( [ "push", "--tags", repoURL, branch ], next, debug || skipRemote );
}
@@ -166,10 +194,12 @@ function steps() {
var cur = 0,
steps = arguments;
(function next(){
- var step = steps[ cur++ ];
- step( next );
+ process.nextTick(function(){
+ steps[ cur++ ]( next );
+ });
})();
}
+
function updatePackageVersion( ver ) {
console.log( "Updating package.json version to " + ver );
pkg.version = ver;
@@ -177,15 +207,18 @@ function updatePackageVersion( ver ) {
fs.writeFileSync( "package.json", JSON.stringify( pkg, null, "\t" ) + "\n" );
}
}
+
function copy( oldFile, newFile ) {
console.log( "Copying " + oldFile + " to " + newFile );
if ( !debug ) {
fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
}
}
+
function git( args, fn, skip ) {
exec( "git", args, fn, skip );
}
+
function exec( cmd, args, fn, skip ) {
if ( skip ) {
console.log( "# " + cmd + " " + args.join(" ") );
@@ -202,10 +235,12 @@ function exec( cmd, args, fn, skip ) {
);
}
}
+
function die( msg ) {
console.error( "ERROR: " + msg );
process.exit( 1 );
}
+
function exit() {
process.exit( 0 );
}