2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-02-11 19:49:47 +00:00
|
|
|
module.exports = function( Release ) {
|
|
|
|
|
2015-11-02 15:41:25 +00:00
|
|
|
var crypto = require( "crypto" );
|
2014-02-11 19:49:47 +00:00
|
|
|
var shell = require( "shelljs" ),
|
2014-05-06 14:23:06 +00:00
|
|
|
path = require( "path" ),
|
|
|
|
fs = require( "fs" );
|
|
|
|
|
|
|
|
function replaceAtVersion() {
|
|
|
|
console.log( "Replacing @VERSION..." );
|
|
|
|
var matches = [];
|
|
|
|
|
|
|
|
function recurse( folder ) {
|
2015-03-06 15:35:10 +00:00
|
|
|
fs.readdirSync( folder ).forEach( function( fileName ) {
|
2014-05-06 14:23:06 +00:00
|
|
|
var content,
|
|
|
|
fullPath = folder + "/" + fileName;
|
|
|
|
if ( fs.statSync( fullPath ).isDirectory() ) {
|
|
|
|
recurse( fullPath );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
content = fs.readFileSync( fullPath, {
|
|
|
|
encoding: "utf-8"
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2014-05-06 14:23:06 +00:00
|
|
|
if ( !/@VERSION/.test( content ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
matches.push( fullPath );
|
|
|
|
fs.writeFileSync( fullPath, content.replace( /@VERSION/g, Release.newVersion ) );
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2014-05-06 14:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[ "ui", "themes" ].forEach( recurse );
|
|
|
|
|
|
|
|
console.log( "Replaced @VERSION in " + matches.length + " files." );
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
}
|
2014-02-11 19:49:47 +00:00
|
|
|
|
2021-06-06 22:58:12 +00:00
|
|
|
function removeExternals( packager ) {
|
2016-09-07 17:38:45 +00:00
|
|
|
Object.keys( packager.builtFiles ).forEach( function( filepath ) {
|
|
|
|
if ( /^external\//.test( filepath ) ) {
|
|
|
|
delete packager.builtFiles[ filepath ];
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2015-11-02 15:41:25 +00:00
|
|
|
function addManifest( packager ) {
|
|
|
|
var output = packager.builtFiles;
|
|
|
|
output.MANIFEST = Object.keys( output ).sort( function( a, b ) {
|
|
|
|
return a.localeCompare( b );
|
|
|
|
} ).map( function( filepath ) {
|
|
|
|
var md5 = crypto.createHash( "md5" );
|
|
|
|
md5.update( output[ filepath ] );
|
|
|
|
return filepath + " " + md5.digest( "hex" );
|
|
|
|
} ).join( "\n" );
|
|
|
|
}
|
|
|
|
|
2014-02-11 19:49:47 +00:00
|
|
|
function buildCDNPackage( callback ) {
|
|
|
|
console.log( "Building CDN package" );
|
2015-11-02 15:41:25 +00:00
|
|
|
var JqueryUi = require( "download.jqueryui.com/lib/jquery-ui" );
|
2024-06-14 17:05:41 +00:00
|
|
|
var PackageWithoutThemes = require( "download.jqueryui.com/lib/package" );
|
|
|
|
var PackageOfThemes = require( "download.jqueryui.com/lib/package-themes" );
|
2015-11-02 15:41:25 +00:00
|
|
|
var Packager = require( "node-packager" );
|
2021-08-04 15:29:48 +00:00
|
|
|
|
|
|
|
// PackageOfThemes doesn't contain JS files, PackageWithoutThemes doesn't contain themes;
|
|
|
|
// we need both.
|
|
|
|
function Package() {
|
|
|
|
|
|
|
|
// PackageOfThemes invokes PackageWithoutThemes's constructor in its own so we don't
|
|
|
|
// need to do it by ourselves; we just need to handle prototypes that way.
|
|
|
|
PackageOfThemes.apply( this, arguments );
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.assign( Package.prototype, PackageWithoutThemes.prototype, PackageOfThemes.prototype );
|
|
|
|
|
2015-11-02 15:41:25 +00:00
|
|
|
var jqueryUi = new JqueryUi( path.resolve( "." ) );
|
2016-03-31 04:30:43 +00:00
|
|
|
var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version +
|
|
|
|
"-cdn.zip" );
|
2015-11-02 15:41:25 +00:00
|
|
|
var packager = new Packager( jqueryUi.files().cache, Package, {
|
|
|
|
components: jqueryUi.components().map( function( component ) {
|
|
|
|
return component.name;
|
2015-03-06 15:35:10 +00:00
|
|
|
} ),
|
2015-11-02 15:41:25 +00:00
|
|
|
jqueryUi: jqueryUi,
|
|
|
|
themeVars: null
|
|
|
|
} );
|
2021-08-06 13:07:00 +00:00
|
|
|
packager.ready
|
|
|
|
.then( function() {
|
|
|
|
removeExternals( packager );
|
|
|
|
addManifest( packager );
|
|
|
|
packager.toZip( target, {
|
|
|
|
basedir: ""
|
|
|
|
}, function( error ) {
|
|
|
|
if ( error ) {
|
|
|
|
Release.abort( "Failed to zip the CDN package", error );
|
|
|
|
}
|
|
|
|
callback();
|
|
|
|
} );
|
|
|
|
} )
|
|
|
|
.catch( function( error ) {
|
|
|
|
Release.abort( "Failed to create the CDN package", error );
|
2015-11-02 15:41:25 +00:00
|
|
|
} );
|
2014-02-11 19:49:47 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:35:10 +00:00
|
|
|
Release.define( {
|
2015-09-29 10:24:38 +00:00
|
|
|
npmPublish: true,
|
2021-10-07 14:48:39 +00:00
|
|
|
issueTracker: "github",
|
2014-02-11 19:49:47 +00:00
|
|
|
changelogShell: function() {
|
|
|
|
var monthNames = [ "January", "February", "March", "April", "May", "June", "July",
|
2015-03-06 15:35:10 +00:00
|
|
|
"August", "September", "October", "November", "December" ],
|
2014-02-11 19:49:47 +00:00
|
|
|
now = new Date();
|
|
|
|
return "<script>{\n\t\"title\": \"jQuery UI " + Release.newVersion + " Changelog\"\n" +
|
2016-03-31 04:30:43 +00:00
|
|
|
"}</script>\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() +
|
|
|
|
", " + now.getFullYear() + "\n\n";
|
2014-02-11 19:49:47 +00:00
|
|
|
},
|
|
|
|
generateArtifacts: function( fn ) {
|
2014-10-30 19:55:08 +00:00
|
|
|
var files = replaceAtVersion();
|
|
|
|
|
2015-03-06 15:35:10 +00:00
|
|
|
buildCDNPackage( function copyCdnFiles() {
|
2014-02-11 19:49:47 +00:00
|
|
|
var zipFile = shell.ls( "../jquery*-cdn.zip" )[ 0 ],
|
|
|
|
tmpFolder = "../tmp-zip-output",
|
|
|
|
unzipCommand = "unzip -o " + zipFile + " -d " + tmpFolder;
|
|
|
|
|
|
|
|
console.log( "Unzipping for dist/cdn copies" );
|
|
|
|
shell.mkdir( "-p", tmpFolder );
|
2015-03-06 15:35:10 +00:00
|
|
|
Release.exec( {
|
2014-02-11 19:49:47 +00:00
|
|
|
command: unzipCommand,
|
|
|
|
silent: true
|
|
|
|
}, "Failed to unzip cdn files" );
|
|
|
|
|
|
|
|
shell.mkdir( "-p", "dist/cdn" );
|
|
|
|
shell.cp( tmpFolder + "/jquery-ui*.js", "dist/cdn" );
|
|
|
|
shell.cp( "-r", tmpFolder + "/themes", "dist/cdn" );
|
2022-03-23 11:05:10 +00:00
|
|
|
|
|
|
|
// Copy all the files to be published on the CDN to the dist directory
|
|
|
|
// as well.
|
|
|
|
shell.cp( "dist/cdn/jquery-ui.js", "dist" );
|
|
|
|
shell.cp( "dist/cdn/jquery-ui.min.js", "dist" );
|
|
|
|
shell.cp( "-r", "dist/cdn/themes", "dist" );
|
|
|
|
|
|
|
|
Release.exec( "git add --force dist/jquery-ui.js",
|
|
|
|
"Error adding dist/jquery-ui.js." );
|
|
|
|
Release.exec( "git add --force dist/jquery-ui.min.js",
|
|
|
|
"Error adding dist/jquery-ui.min.js." );
|
|
|
|
Release.exec( "git add --force dist/themes",
|
|
|
|
"Error adding dist/themes." );
|
|
|
|
|
2014-05-06 14:23:06 +00:00
|
|
|
fn( files );
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2014-02-11 19:49:47 +00:00
|
|
|
}
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2014-02-11 19:49:47 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.dependencies = [
|
2024-07-05 16:53:40 +00:00
|
|
|
"download.jqueryui.com@2.3.7",
|
2024-04-22 16:08:44 +00:00
|
|
|
"node-packager@0.0.7",
|
|
|
|
"shelljs@0.8.5"
|
2014-02-11 19:49:47 +00:00
|
|
|
];
|