mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-22 23:23:30 -06:00
WebUI build: replace uglifyjs with system package
UgligyJS is packaged in Fedora and other OSes it is no longer required to carry our own version. This will lower the maintanance burden - the code doesn't need to be updated and it is less code to have in repo. On some configuration usage of the budled UglifyJS 1 produces "JavaScript throw: java.lang.StackOverflowError" exception. Usage of more recent version should fix it. Reviewed-By: Armando Neto <abiagion@redhat.com>
This commit is contained in:
parent
f89e501ee1
commit
ca7cece133
@ -157,6 +157,7 @@ BuildRequires: libsss_certmap-devel
|
||||
# 1.15.3: sss_nss_getlistbycert (https://pagure.io/SSSD/sssd/issue/3050)
|
||||
BuildRequires: libsss_nss_idmap-devel >= 1.15.3
|
||||
BuildRequires: rhino
|
||||
BuildRequires: uglify-js
|
||||
BuildRequires: libverto-devel
|
||||
BuildRequires: libunistring-devel
|
||||
# 0.13.0: https://bugzilla.redhat.com/show_bug.cgi?id=1584773
|
||||
|
@ -27,10 +27,6 @@ QUnit - dual licensed under MIT and GPLv2 licenses
|
||||
Font Awesome - code licensed under MIT license
|
||||
* less/font-awesome
|
||||
|
||||
UglifyJS - licensed under BSD license
|
||||
* util/uglifyjs/uglify-js.js
|
||||
* utli/uglifyjs/lib/*
|
||||
|
||||
Dojo, Dojo Builder - dual licensed under BSD license and AFL version 2.1
|
||||
* full license text in util/build/LICENSE
|
||||
* util/build/build.js
|
||||
|
@ -105,5 +105,7 @@ if [[ ! $OUTPUT_FILE ]] ; then
|
||||
OUTPUT_FILE=$RDIR/$RELEASE/$LAYER.js
|
||||
fi
|
||||
|
||||
# compile using uglify.js
|
||||
$DIR/uglifyjs/uglify $RDIR/$RELEASE/$LAYER.js $OUTPUT_FILE
|
||||
# compile using uglifyjs
|
||||
echo "Minimizing: $RDIR/$RELEASE/$LAYER.js"
|
||||
echo "Target file: $OUTPUT_FILE"
|
||||
uglifyjs $RDIR/$RELEASE/$LAYER.js > $OUTPUT_FILE
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
||||
var jsp = require("./parse-js"),
|
||||
pro = require("./process"),
|
||||
slice = jsp.slice,
|
||||
member = jsp.member,
|
||||
curry = jsp.curry,
|
||||
MAP = pro.MAP,
|
||||
PRECEDENCE = jsp.PRECEDENCE,
|
||||
OPERATORS = jsp.OPERATORS;
|
||||
|
||||
function ast_squeeze_more(ast) {
|
||||
var w = pro.ast_walker(), walk = w.walk, scope;
|
||||
function with_scope(s, cont) {
|
||||
var save = scope, ret;
|
||||
scope = s;
|
||||
ret = cont();
|
||||
scope = save;
|
||||
return ret;
|
||||
};
|
||||
function _lambda(name, args, body) {
|
||||
return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
|
||||
};
|
||||
return w.with_walkers({
|
||||
"toplevel": function(body) {
|
||||
return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
|
||||
},
|
||||
"function": _lambda,
|
||||
"defun": _lambda,
|
||||
"new": function(ctor, args) {
|
||||
if (ctor[0] == "name") {
|
||||
if (ctor[1] == "Array" && !scope.has("Array")) {
|
||||
if (args.length != 1) {
|
||||
return [ "array", args ];
|
||||
} else {
|
||||
return walk([ "call", [ "name", "Array" ], args ]);
|
||||
}
|
||||
} else if (ctor[1] == "Object" && !scope.has("Object")) {
|
||||
if (!args.length) {
|
||||
return [ "object", [] ];
|
||||
} else {
|
||||
return walk([ "call", [ "name", "Object" ], args ]);
|
||||
}
|
||||
} else if ((ctor[1] == "RegExp" || ctor[1] == "Function" || ctor[1] == "Error") && !scope.has(ctor[1])) {
|
||||
return walk([ "call", [ "name", ctor[1] ], args]);
|
||||
}
|
||||
}
|
||||
},
|
||||
"call": function(expr, args) {
|
||||
if (expr[0] == "dot" && expr[1][0] == "string" && args.length == 1
|
||||
&& (args[0][1] > 0 && expr[2] == "substring" || expr[2] == "substr")) {
|
||||
return [ "call", [ "dot", expr[1], "slice"], args];
|
||||
}
|
||||
if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
|
||||
// foo.toString() ==> foo+""
|
||||
if (expr[1][0] == "string") return expr[1];
|
||||
return [ "binary", "+", expr[1], [ "string", "" ]];
|
||||
}
|
||||
if (expr[0] == "name") {
|
||||
if (expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
|
||||
return [ "array", args ];
|
||||
}
|
||||
if (expr[1] == "Object" && !args.length && !scope.has("Object")) {
|
||||
return [ "object", [] ];
|
||||
}
|
||||
if (expr[1] == "String" && !scope.has("String")) {
|
||||
return [ "binary", "+", args[0], [ "string", "" ]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}, function() {
|
||||
return walk(pro.ast_add_scope(ast));
|
||||
});
|
||||
};
|
||||
|
||||
exports.ast_squeeze_more = ast_squeeze_more;
|
||||
|
||||
// Local variables:
|
||||
// js-indent-level: 4
|
||||
// End:
|
@ -1 +0,0 @@
|
||||
//just empty file to make rhino happy
|
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Authors:
|
||||
# Petr Vobornik <pvoborni@redhat.com>
|
||||
#
|
||||
# Copyright (C) 2012 Red Hat
|
||||
# see file 'COPYING' for use and warranty information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Wrapper for calling uglify.js under rhino
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# rhino-1.7R4 doesn't have -main option to enable CommonJS support. It was
|
||||
# replaced by -require option.
|
||||
RHINO="java -Xss${JAVA_STACK_SIZE:-512k} -classpath /usr/share/java/js.jar org.mozilla.javascript.tools.shell.Main"
|
||||
if [ `$RHINO --help | grep -e -require | wc -l` -gt 0 ] ; then
|
||||
$RHINO -require $DIR/uglify-js.js $@
|
||||
else
|
||||
$RHINO -main $DIR/uglify-js.js $DIR/ug.js $@
|
||||
fi
|
@ -1,86 +0,0 @@
|
||||
// Modified version of the orignal uglify-js.js. Modified to be runnable
|
||||
// under rhino by Petr Vobornik, Red Hat
|
||||
// writeFile(), read() code written by John Resig.
|
||||
|
||||
function uglify(orig_code, options){
|
||||
options || (options = {});
|
||||
var jsp = uglify.parser;
|
||||
var pro = uglify.uglify;
|
||||
|
||||
var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST
|
||||
ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names
|
||||
ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations
|
||||
var final_code = pro.gen_code(ast, options.gen_options); // compressed code here
|
||||
return final_code;
|
||||
};
|
||||
|
||||
uglify.parser = require("./lib/parse-js");
|
||||
uglify.uglify = require("./lib/process");
|
||||
uglify.consolidator = require("./lib/consolidator");
|
||||
|
||||
module.exports = uglify
|
||||
|
||||
|
||||
importPackage(java.io);
|
||||
|
||||
function writeFile( file, stream ) {
|
||||
var buffer = new PrintWriter( new FileWriter( file ) );
|
||||
buffer.print( stream );
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
function read( file ) {
|
||||
var f = new File(file);
|
||||
var reader = new BufferedReader(new FileReader(f));
|
||||
var line = null;
|
||||
var buffer = new java.lang.StringBuffer(f.length());
|
||||
while( (line = reader.readLine()) != null) {
|
||||
buffer.append(line);
|
||||
buffer.append("\n");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
var options = {
|
||||
ast: false,
|
||||
consolidate: false,
|
||||
mangle: true,
|
||||
mangle_toplevel: false,
|
||||
no_mangle_functions: false,
|
||||
squeeze: true,
|
||||
make_seqs: true,
|
||||
dead_code: true,
|
||||
verbose: false,
|
||||
show_copyright: true,
|
||||
out_same_file: false,
|
||||
max_line_length: 32 * 1024,
|
||||
unsafe: false,
|
||||
reserved_names: null,
|
||||
defines: { },
|
||||
lift_vars: false,
|
||||
codegen_options: {
|
||||
ascii_only: false,
|
||||
beautify: false,
|
||||
indent_level: 4,
|
||||
indent_start: 0,
|
||||
quote_keys: false,
|
||||
space_colon: false,
|
||||
inline_script: false
|
||||
},
|
||||
make: false,
|
||||
output: true // stdout
|
||||
};
|
||||
|
||||
if (arguments.length < 2) {
|
||||
print('Invalid input\nUsage: uglify inputFile outputFile');
|
||||
quit();
|
||||
}
|
||||
|
||||
if (arguments.indexOf('-v')) {
|
||||
print('Uglifying '+arguments[0] +'\nOutput: '+arguments[1]);
|
||||
}
|
||||
|
||||
//read input file
|
||||
var input = read(arguments[0]) + '';
|
||||
var output = uglify(input, options);
|
||||
writeFile(arguments[1], output);
|
Loading…
Reference in New Issue
Block a user