[Libreoffice-commits] online.git: loleaflet/build loleaflet/plugins

Henry Castro hcastro at collabora.com
Sun May 27 04:28:37 UTC 2018


 loleaflet/build/build.js                    |  207 ----------------------------
 loleaflet/plugins/draw-0.2.4/build/build.js |  104 --------------
 2 files changed, 2 insertions(+), 309 deletions(-)

New commits:
commit 8002a4cb9b17df9578412d1eb1967164b81c8a63
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun May 27 00:26:59 2018 -0400

    loleaflet: remove unused build code
    
    Change-Id: I43dc41ba73ed9aac20f427cb5ff81d971849f547

diff --git a/loleaflet/build/build.js b/loleaflet/build/build.js
index 9e4082269..c2cad9a05 100644
--- a/loleaflet/build/build.js
+++ b/loleaflet/build/build.js
@@ -1,52 +1,4 @@
-var fs = require('fs'),
-    UglifyJS = require('uglify-js'),
-    zlib = require('zlib'),
-    browserify = require('browserify'),
-    browserifyCss = require('browserify-css'),
-    exorcist = require('exorcist'),
-    builddir = process.env.builddir ? process.env.builddir + '/' : '',
-    deps = require('./deps.js').deps,
-    adminDeps = require('./adminDeps.js').adminDeps;
-
-// TODO: Don't hardcode leaflet-draw version here
-var JSBundleFiles = [
-	'main.js',
-	'dist/leaflet-src.js',
-	'dist/errormessages.js',
-	'unocommands.js',
-	'dist/plugins/draw-0.2.4/dist/leaflet.draw.js'
-];
-
-var CSSBundleFiles = [
-	'main.css',
-	'dist/leaflet.css',
-	'dist/selectionMarkers.css',
-	'dist/loleaflet.css',
-	'dist/toolbar.css',
-	'dist/partsPreviewControl.css',
-	'dist/scrollBar.css',
-	'dist/searchControl.css',
-	'dist/spreadsheet.css',
-	'dist/menubar.css',
-	'plugins/draw-0.2.4/dist/leaflet.draw.css',
-];
-
-var adminBundleFiles = [
-	'main-admin.js',
-	builddir + 'dist/admin-src.js',
-	'admin/bootstrap/ie10-viewport-bug-workaround.css',
-	'admin.strings.js',
-	'admin/bootstrap/holder.min.js',
-	'admin/bootstrap/ie10-viewport-bug-workaround.js'
-];
-
-exports.getBundleFiles = function() {
-	return JSBundleFiles.concat(CSSBundleFiles);
-};
-
-exports.getAdminBundleFiles = function() {
-	return adminBundleFiles;
-};
+var deps = require('./deps.js').deps;
 
 function getFiles(compsBase32) {
 	var memo = {},
@@ -87,164 +39,7 @@ function getFiles(compsBase32) {
 	return files;
 }
 
-function getAdminFiles() {
-	var files = [];
-
-	for (var i in adminDeps) {
-		for (var j = 0, len = adminDeps[i].src.length; j < len; j++) {
-			files.push('src/' + adminDeps[i].src[j]);
-		}
-	}
-
-	return files;
-}
-
 exports.getFiles = getFiles;
-exports.getAdminFiles = getAdminFiles;
-
-function getSizeDelta(newContent, oldContent, fixCRLF) {
-	if (!oldContent) {
-		return ' (new)';
-	}
-	if (newContent === oldContent) {
-		return ' (unchanged)';
-	}
-	if (fixCRLF) {
-		newContent = newContent.replace(/\r\n?/g, '\n');
-		oldContent = oldContent.replace(/\r\n?/g, '\n');
-	}
-	var delta = newContent.length - oldContent.length;
-
-	return delta === 0 ? '' : ' (' + (delta > 0 ? '+' : '') + delta + ' bytes)';
-}
-
-function loadSilently(path) {
-	try {
-		return fs.readFileSync(path, 'utf8');
-	} catch (e) {
-		return null;
-	}
-}
-
-function combineFiles(files) {
-	var content = '';
-	for (var i = 0, len = files.length; i < len; i++) {
-		content += fs.readFileSync(files[i], 'utf8') + '\n\n';
-	}
-	return content;
-}
-
-function bytesToKB(bytes) {
-    return (bytes / 1024).toFixed(2) + ' KB';
-}
-
-function bundle(files, destFilename, debug, minify, callback) {
-	var node_paths = builddir !== '' ? [builddir + 'node_modules', builddir + 'dist'] :
-		[process.cwd() +'/node_modules', process.cwd() + '/dist']
-	var bundler = browserify(files, {debug: debug, paths:node_paths});
-	bundler = bundler.transform(browserifyCss, {global:true});
-	if (minify) {
-		console.log('uglifying');
-		bundler.transform({
-			global: true
-		}, 'uglifyify');
-	}
-	var bundleFs = fs.createWriteStream(builddir + 'dist/' + destFilename);
-	var res = bundler.bundle();
-	if (debug) {
-		res = res.pipe(exorcist(builddir + 'dist/' + destFilename + '.map'));
-	}
-	res.pipe(bundleFs);
-
-	bundleFs.on('finish', function() {
-		console.log('Finish writing to dist/' + destFilename);
-		callback();
-	});
-};
-
-exports.bundle = function(debug, minify, callback) {
-	bundle(['main.js'], 'bundle.js', debug, minify, callback);
-};
-
-exports.bundleAdmin = function(debug, minify, callback) {
-	bundle(['main-admin.js'], 'admin-bundle.js', debug, minify, callback);
-};
-
-exports.build = function (callback, version, compsBase32, buildName) {
-
-	var files = getFiles(compsBase32);
-
-	console.log('Concatenating and compressing ' + files.length + ' files...');
-
-	var copy = fs.readFileSync('src/copyright.js', 'utf8').replace('{VERSION}', version),
-	    intro = '(function (window, document, undefined) {',
-	    outro = '}(window, document));',
-	    newSrc = copy + intro + combineFiles(files) + outro,
-
-	    pathPart = 'dist/leaflet' + (buildName ? '-' + buildName : ''),
-	    srcPath = pathPart + '-src.js',
-
-	    oldSrc = loadSilently(srcPath),
-	    srcDelta = getSizeDelta(newSrc, oldSrc, true);
-
-	console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
-
-	if (newSrc !== oldSrc) {
-		fs.writeFileSync(srcPath, newSrc);
-		console.log('\tSaved to ' + srcPath);
-	}
-
-	var path = pathPart + '.js',
-	    oldCompressed = loadSilently(path),
-	    newCompressed = copy + UglifyJS.minify(newSrc, {
-	        warnings: true,
-	        fromString: true
-	    }).code,
-	    delta = getSizeDelta(newCompressed, oldCompressed);
-
-	console.log('\tCompressed: ' + bytesToKB(newCompressed.length) + delta);
-
-	var newGzipped,
-	    gzippedDelta = '';
-
-	function done() {
-		if (newCompressed !== oldCompressed) {
-			fs.writeFileSync(path, newCompressed);
-			console.log('\tSaved to ' + path);
-		}
-		console.log('\tGzipped: ' + bytesToKB(newGzipped.length) + gzippedDelta);
-		callback();
-	}
-
-	zlib.gzip(newCompressed, function (err, gzipped) {
-		if (err) { return; }
-		newGzipped = gzipped;
-		if (oldCompressed && (oldCompressed !== newCompressed)) {
-			zlib.gzip(oldCompressed, function (err, oldGzipped) {
-				if (err) { return; }
-				gzippedDelta = getSizeDelta(gzipped, oldGzipped);
-				done();
-			});
-		} else {
-			done();
-		}
-	});
-};
-
-exports.buildadmin = function(callback) {
-	// TODO: Also minify if admin complexity increases in future
-	var adminNewSrc = combineFiles(getAdminFiles()),
-	    adminPath = builddir + 'dist/admin-src.js',
-	    adminOldSrc = loadSilently(adminPath),
-	    adminSrcDelta = getSizeDelta(adminNewSrc, adminOldSrc, true);
-
-	if (adminSrcDelta !== ' (unchanged)') {
-		fs.writeFileSync(adminPath, adminNewSrc);
-		console.log('\tAdmin files saved to ' + adminPath);
-	}
-
-	callback();
-};
 
 exports.test = function(complete, fail) {
 	var karma = require('karma'),
diff --git a/loleaflet/plugins/draw-0.2.4/build/build.js b/loleaflet/plugins/draw-0.2.4/build/build.js
index e72dcca1a..8a6b2f005 100644
--- a/loleaflet/plugins/draw-0.2.4/build/build.js
+++ b/loleaflet/plugins/draw-0.2.4/build/build.js
@@ -1,8 +1,4 @@
-var fs = require('fs'),
-	UglifyJS = require('uglify-js'),
-	zlib = require('zlib'),
-	builddir = process.env.builddir ? process.env.builddir + '/' : '',
-	deps = require('./deps.js').deps;
+var deps = require('./deps.js').deps;
 
 function getFiles(compsBase32) {
 	var memo = {},
@@ -45,104 +41,6 @@ function getFiles(compsBase32) {
 
 exports.getFiles = getFiles;
 
-function getSizeDelta(newContent, oldContent, fixCRLF) {
-		if (!oldContent) {
-				return ' (new)';
-		}
-		if (newContent === oldContent) {
-				return ' (unchanged)';
-		}
-		if (fixCRLF) {
-				newContent = newContent.replace(/\r\n?/g, '\n');
-				oldContent = oldContent.replace(/\r\n?/g, '\n');
-		}
-		var delta = newContent.length - oldContent.length;
-
-		return delta === 0 ? '' : ' (' + (delta > 0 ? '+' : '') + delta + ' bytes)';
-}
-
-function loadSilently(path) {
-		try {
-				return fs.readFileSync(path, 'utf8');
-		} catch (e) {
-				return null;
-		}
-}
-
-function combineFiles(files) {
-		var content = '';
-		for (var i = 0, len = files.length; i < len; i++) {
-				content += fs.readFileSync(files[i], 'utf8') + '\n\n';
-		}
-		return content;
-}
-
-function bytesToKB(bytes) {
-	return (bytes / 1024).toFixed(2) + ' KB';
-}
-
-exports.build = function (callback, compsBase32, buildName) {
-	var files = getFiles(compsBase32);
-
-	console.log('Concatenating and compressing ' + files.length + ' files...');
-
-	var copy = fs.readFileSync('src/copyright.js', 'utf8'),
-		intro = '(function (window, document, undefined) {',
-		outro = '}(window, document));',
-		newSrc = copy + intro + combineFiles(files) + outro,
-
-		pathPart = builddir + 'dist/leaflet.draw' + (buildName ? '-' + buildName : ''),
-		srcPath = pathPart + '-src.js',
-
-		oldSrc = loadSilently(srcPath),
-		srcDelta = getSizeDelta(newSrc, oldSrc, true);
-
-	console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
-
-	if (srcDelta === ' (unchanged)') {
-		return;
-	}
-
-	fs.writeFileSync(srcPath, newSrc);
-	console.log('\tSaved to ' + srcPath);
-
-	var path = pathPart + '.js',
-		oldCompressed = loadSilently(path),
-		newCompressed = copy + UglifyJS.minify(newSrc, {
-			warnings: true,
-			fromString: true
-		}).code,
-		delta = getSizeDelta(newCompressed, oldCompressed);
-
-	console.log('\tCompressed: ' + bytesToKB(newCompressed.length) + delta);
-
-	var newGzipped,
-		gzippedDelta = '';
-
-	function done() {
-		if (newCompressed !== oldCompressed) {
-			fs.writeFileSync(path, newCompressed);
-			console.log('\tSaved to ' + path);
-		}
-		console.log('\tGzipped: ' + bytesToKB(newGzipped.length) + gzippedDelta);
-		callback();
-	}
-
-	zlib.gzip(newCompressed, function (err, gzipped) {
-		if (err) { return; }
-		newGzipped = gzipped;
-		if (oldCompressed && (oldCompressed !== newCompressed)) {
-			zlib.gzip(oldCompressed, function (err, oldGzipped) {
-				if (err) { return; }
-				gzippedDelta = getSizeDelta(gzipped, oldGzipped);
-				done();
-			});
-		} else {
-			done();
-		}
-	});
-};
-
 exports.test = function(callback) {
 		var karma = require('karma'),
 		testConfig = {configFile : __dirname + '/../spec/karma.conf.js'};


More information about the Libreoffice-commits mailing list