2015-11-12 18:18:59 +00:00
|
|
|
|
module.exports = function( Release, files, complete ) {
|
2015-01-28 19:37:29 +00:00
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
fs = require( "fs" ),
|
|
|
|
|
shell = require( "shelljs" ),
|
|
|
|
|
pkg = require( Release.dir.repo + "/package.json" ),
|
2015-11-12 18:18:59 +00:00
|
|
|
|
distRemote = Release.remote
|
|
|
|
|
|
|
|
|
|
// For local and github dists
|
|
|
|
|
.replace( /jquery(\.git|$)/, "jquery-dist$1" ),
|
2015-08-16 06:59:58 +00:00
|
|
|
|
|
2015-07-30 13:34:34 +00:00
|
|
|
|
// These files are included with the distribution
|
2015-11-12 18:18:59 +00:00
|
|
|
|
extras = [
|
2015-01-28 19:37:29 +00:00
|
|
|
|
"src",
|
|
|
|
|
"LICENSE.txt",
|
|
|
|
|
"AUTHORS.txt",
|
|
|
|
|
"package.json"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clone the distribution repo
|
|
|
|
|
*/
|
|
|
|
|
function clone() {
|
|
|
|
|
Release.chdir( Release.dir.base );
|
|
|
|
|
Release.dir.dist = Release.dir.base + "/dist";
|
|
|
|
|
|
|
|
|
|
console.log( "Using distribution repo: ", distRemote );
|
|
|
|
|
Release.exec( "git clone " + distRemote + " " + Release.dir.dist,
|
|
|
|
|
"Error cloning repo." );
|
|
|
|
|
|
|
|
|
|
// Distribution always works on master
|
|
|
|
|
Release.chdir( Release.dir.dist );
|
|
|
|
|
Release.exec( "git checkout master", "Error checking out branch." );
|
|
|
|
|
console.log();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate bower file for jquery-dist
|
|
|
|
|
*/
|
|
|
|
|
function generateBower() {
|
2015-08-16 06:59:58 +00:00
|
|
|
|
return JSON.stringify( {
|
2015-01-28 19:37:29 +00:00
|
|
|
|
name: pkg.name,
|
|
|
|
|
main: pkg.main,
|
|
|
|
|
license: "MIT",
|
|
|
|
|
ignore: [
|
|
|
|
|
"package.json"
|
|
|
|
|
],
|
|
|
|
|
keywords: pkg.keywords
|
2015-08-16 06:59:58 +00:00
|
|
|
|
}, null, 2 );
|
2015-01-28 19:37:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-17 16:30:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replace the version in the README
|
|
|
|
|
* @param {string} readme
|
|
|
|
|
*/
|
|
|
|
|
function editReadme( readme ) {
|
|
|
|
|
var rprev = new RegExp( Release.prevVersion, "g" );
|
|
|
|
|
return readme.replace( rprev, Release.newVersion );
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-28 19:37:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* Copy necessary files over to the dist repo
|
|
|
|
|
*/
|
|
|
|
|
function copy() {
|
|
|
|
|
|
|
|
|
|
// Copy dist files
|
2016-05-09 15:57:31 +00:00
|
|
|
|
var distFolder = Release.dir.dist + "/dist",
|
2016-05-09 17:53:03 +00:00
|
|
|
|
externalFolder = Release.dir.dist + "/external",
|
2017-03-17 16:30:55 +00:00
|
|
|
|
readme = fs.readFileSync( Release.dir.dist + "/README.md", "utf8" ),
|
2016-05-09 17:53:03 +00:00
|
|
|
|
rmIgnore = files
|
|
|
|
|
.concat( [
|
|
|
|
|
"README.md",
|
|
|
|
|
"node_modules"
|
|
|
|
|
] )
|
|
|
|
|
.map( function( file ) {
|
|
|
|
|
return Release.dir.dist + "/" + file;
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
shell.config.globOptions = {
|
|
|
|
|
ignore: rmIgnore
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Remove extraneous files before copy
|
|
|
|
|
shell.rm( "-rf", Release.dir.dist + "/**/*" );
|
2016-05-09 15:57:31 +00:00
|
|
|
|
|
2015-01-28 19:37:29 +00:00
|
|
|
|
shell.mkdir( "-p", distFolder );
|
2015-11-12 18:18:59 +00:00
|
|
|
|
files.forEach( function( file ) {
|
|
|
|
|
shell.cp( "-f", Release.dir.repo + "/" + file, distFolder );
|
2015-08-16 06:59:58 +00:00
|
|
|
|
} );
|
2015-01-28 19:37:29 +00:00
|
|
|
|
|
2016-05-09 15:57:31 +00:00
|
|
|
|
// Copy Sizzle
|
|
|
|
|
shell.mkdir( "-p", externalFolder );
|
|
|
|
|
shell.cp( "-rf", Release.dir.repo + "/external/sizzle", externalFolder );
|
|
|
|
|
|
2015-01-28 19:37:29 +00:00
|
|
|
|
// Copy other files
|
2015-11-12 18:18:59 +00:00
|
|
|
|
extras.forEach( function( file ) {
|
|
|
|
|
shell.cp( "-rf", Release.dir.repo + "/" + file, Release.dir.dist );
|
2015-08-16 06:59:58 +00:00
|
|
|
|
} );
|
2015-01-28 19:37:29 +00:00
|
|
|
|
|
2016-03-09 17:06:17 +00:00
|
|
|
|
// Remove the wrapper from the dist repo
|
|
|
|
|
shell.rm( "-f", Release.dir.dist + "/src/wrapper.js" );
|
|
|
|
|
|
2015-01-28 19:37:29 +00:00
|
|
|
|
// Write generated bower file
|
|
|
|
|
fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() );
|
|
|
|
|
|
2017-03-17 16:30:55 +00:00
|
|
|
|
fs.writeFileSync( Release.dir.dist + "/README.md", editReadme( readme ) );
|
|
|
|
|
|
|
|
|
|
console.log( "Files ready to add." );
|
|
|
|
|
console.log( "Edit the dist README.md to include the latest blog post link." );
|
|
|
|
|
}
|
2016-09-22 21:55:01 +00:00
|
|
|
|
|
2017-03-17 16:30:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* Add, commit, and tag the dist files
|
|
|
|
|
*/
|
|
|
|
|
function commit() {
|
|
|
|
|
console.log( "Adding files to dist..." );
|
2016-09-22 21:55:01 +00:00
|
|
|
|
Release.exec( "git add -A", "Error adding files." );
|
2015-01-28 19:37:29 +00:00
|
|
|
|
Release.exec(
|
2016-09-22 21:55:01 +00:00
|
|
|
|
"git commit -m \"Release " + Release.newVersion + "\"",
|
2015-12-04 06:49:23 +00:00
|
|
|
|
"Error committing files."
|
2015-01-28 19:37:29 +00:00
|
|
|
|
);
|
|
|
|
|
console.log();
|
|
|
|
|
|
|
|
|
|
console.log( "Tagging release on dist..." );
|
|
|
|
|
Release.exec( "git tag " + Release.newVersion,
|
|
|
|
|
"Error tagging " + Release.newVersion + " on dist repo." );
|
2016-09-22 21:55:01 +00:00
|
|
|
|
Release.tagTime = Release.exec( "git log -1 --format=\"%ad\"",
|
2015-01-28 19:37:29 +00:00
|
|
|
|
"Error getting tag timestamp." ).trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Push files to dist repo
|
|
|
|
|
*/
|
|
|
|
|
function push() {
|
|
|
|
|
Release.chdir( Release.dir.dist );
|
|
|
|
|
|
|
|
|
|
console.log( "Pushing release to dist repo..." );
|
2015-01-30 20:46:48 +00:00
|
|
|
|
Release.exec( "git push " + distRemote + " master --tags",
|
2015-01-28 19:37:29 +00:00
|
|
|
|
"Error pushing master and tags to git repo." );
|
|
|
|
|
|
|
|
|
|
// Set repo for npm publish
|
|
|
|
|
Release.dir.origRepo = Release.dir.repo;
|
|
|
|
|
Release.dir.repo = Release.dir.dist;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-29 23:36:48 +00:00
|
|
|
|
Release.walk( [
|
2015-01-28 19:37:29 +00:00
|
|
|
|
Release._section( "Copy files to distribution repo" ),
|
|
|
|
|
clone,
|
|
|
|
|
copy,
|
|
|
|
|
Release.confirmReview,
|
|
|
|
|
|
2017-03-17 16:30:55 +00:00
|
|
|
|
Release._section( "Add, commit, and tag files in distribution repo" ),
|
|
|
|
|
commit,
|
|
|
|
|
Release.confirmReview,
|
|
|
|
|
|
2015-01-28 19:37:29 +00:00
|
|
|
|
Release._section( "Pushing files to distribution repo" ),
|
|
|
|
|
push
|
2015-01-29 23:36:48 +00:00
|
|
|
|
], complete );
|
2015-01-28 19:37:29 +00:00
|
|
|
|
};
|