summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2015-03-17 15:12:39 +0100
committerRemi Collet <fedora@famillecollet.com>2015-03-17 15:12:39 +0100
commit155f13ffad1288e6dc9eb31fb2a1443590c943a2 (patch)
tree6479b20b58a17595a9be736a659a0b710f1af6ee
php-patchwork-jsqueeze: import from rawhide
-rw-r--r--Makefile4
-rw-r--r--dc3c4073c2060d62a8578848c5d222a8b7608df1.patch68
-rw-r--r--f3747ee91e3025b46e29b2128bbb83f63cbb7f2a.patch60
-rw-r--r--php-patchwork-jsqueeze.spec86
4 files changed, 218 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..91b0fd5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+SRCDIR := $(shell pwd)
+NAME := $(shell basename $(SRCDIR))
+include ../../common/Makefile
+
diff --git a/dc3c4073c2060d62a8578848c5d222a8b7608df1.patch b/dc3c4073c2060d62a8578848c5d222a8b7608df1.patch
new file mode 100644
index 0000000..6cc4e69
--- /dev/null
+++ b/dc3c4073c2060d62a8578848c5d222a8b7608df1.patch
@@ -0,0 +1,68 @@
+From dc3c4073c2060d62a8578848c5d222a8b7608df1 Mon Sep 17 00:00:00 2001
+From: Nicolas Grekas <nicolas.grekas@gmail.com>
+Date: Mon, 16 Mar 2015 19:14:38 +0100
+Subject: [PATCH] Fix #15 when ";" is missing before else/while
+
+---
+ src/JSqueeze.php | 1 +
+ tests/uglifyjs/expected/if.js | 3 ++-
+ tests/uglifyjs/expected/ifreturn.js | 3 ++-
+ tests/uglifyjs/expected/issue10.js | 3 ++-
+ tests/uglifyjs/expected/tchwork-15.js | 2 ++
+ tests/uglifyjs/test/tchwork-15.js | 2 ++
+ 6 files changed, 11 insertions(+), 3 deletions(-)
+ create mode 100644 tests/uglifyjs/expected/tchwork-15.js
+ create mode 100644 tests/uglifyjs/test/tchwork-15.js
+
+diff --git a/src/JSqueeze.php b/src/JSqueeze.php
+index b85edeb..e6da80e 100644
+--- a/src/JSqueeze.php
++++ b/src/JSqueeze.php
+@@ -162,6 +162,7 @@ function squeeze($code, $singleLine = true, $keepImportantComments = true, $spec
+
+ $code = substr($tree[$key]['code'], 1);
+ $code = preg_replace("'\breturn !'", 'return!', $code);
++ $code = preg_replace("'\}(?=(else|while)[^\$.a-zA-Z0-9_])'", "}\r", $code);
+ $code = str_replace(array_keys($this->strings), array_values($this->strings), $code);
+
+ if ($singleLine) $code = strtr($code, "\n", ';');
+diff --git a/tests/uglifyjs/expected/if.js b/tests/uglifyjs/expected/if.js
+index c347e25..7f4fde1 100644
+--- a/tests/uglifyjs/expected/if.js
++++ b/tests/uglifyjs/expected/if.js
+@@ -1 +1,2 @@
+-;var a=1;if(a==1){a=2}else{a=17};
++;var a=1;if(a==1){a=2}
++else{a=17};
+diff --git a/tests/uglifyjs/expected/ifreturn.js b/tests/uglifyjs/expected/ifreturn.js
+index ec6b59d..1a85e9c 100644
+--- a/tests/uglifyjs/expected/ifreturn.js
++++ b/tests/uglifyjs/expected/ifreturn.js
+@@ -1 +1,2 @@
+-;function a(r){if(r==1){return 2}else{return 17};return 3};
++;function a(r){if(r==1){return 2}
++else{return 17};return 3};
+diff --git a/tests/uglifyjs/expected/issue10.js b/tests/uglifyjs/expected/issue10.js
+index afa9e0c..ec193b0 100644
+--- a/tests/uglifyjs/expected/issue10.js
++++ b/tests/uglifyjs/expected/issue10.js
+@@ -1 +1,2 @@
+-;function f(){var r;if(r='a'){return r}else{return r}};f();
++;function f(){var r;if(r='a'){return r}
++else{return r}};f();
+diff --git a/tests/uglifyjs/expected/tchwork-15.js b/tests/uglifyjs/expected/tchwork-15.js
+new file mode 100644
+index 0000000..59972e2
+--- /dev/null
++++ b/tests/uglifyjs/expected/tchwork-15.js
+@@ -0,0 +1,2 @@
++;if(foo)var bar=function(){}
++else baz;
+diff --git a/tests/uglifyjs/test/tchwork-15.js b/tests/uglifyjs/test/tchwork-15.js
+new file mode 100644
+index 0000000..cbe8c16
+--- /dev/null
++++ b/tests/uglifyjs/test/tchwork-15.js
+@@ -0,0 +1,2 @@
++if (foo) var bar = function() {}
++else baz;
diff --git a/f3747ee91e3025b46e29b2128bbb83f63cbb7f2a.patch b/f3747ee91e3025b46e29b2128bbb83f63cbb7f2a.patch
new file mode 100644
index 0000000..5fe14e3
--- /dev/null
+++ b/f3747ee91e3025b46e29b2128bbb83f63cbb7f2a.patch
@@ -0,0 +1,60 @@
+From f3747ee91e3025b46e29b2128bbb83f63cbb7f2a Mon Sep 17 00:00:00 2001
+From: Nicolas Grekas <nicolas.grekas@gmail.com>
+Date: Sat, 7 Mar 2015 18:48:17 +0100
+Subject: [PATCH] Fix #16 name collision with NFEs
+
+---
+ src/JSqueeze.php | 1 +
+ tests/uglifyjs/expected/mangle.js | 2 +-
+ tests/uglifyjs/expected/tchwork-16.js | 1 +
+ tests/uglifyjs/test/mangle.js | 1 +
+ tests/uglifyjs/test/tchwork-16.js | 3 +++
+ 5 files changed, 7 insertions(+), 1 deletion(-)
+ create mode 100644 tests/uglifyjs/expected/tchwork-16.js
+ create mode 100644 tests/uglifyjs/test/tchwork-16.js
+
+diff --git a/src/JSqueeze.php b/src/JSqueeze.php
+index fc92ce4..b85edeb 100644
+--- a/src/JSqueeze.php
++++ b/src/JSqueeze.php
+@@ -857,6 +857,7 @@ protected function renameVars(&$tree, $root)
+ else
+ {
+ arsort($tree['local']);
++ if (false !== $tree['nfe']) $tree['used'][] = $tree['local'][$tree['nfe']];
+
+ foreach ($tree['local'] as $var => $root)
+ if ($tree['nfe'] !== $var)
+diff --git a/tests/uglifyjs/expected/mangle.js b/tests/uglifyjs/expected/mangle.js
+index 6e51d91..eb8f7f7 100644
+--- a/tests/uglifyjs/expected/mangle.js
++++ b/tests/uglifyjs/expected/mangle.js
+@@ -1 +1 @@
+-(function(){var r=function n(r,n,n){return n}}());
++(function(){var u=function n(r,n,u){return n};u=fun}());
+diff --git a/tests/uglifyjs/expected/tchwork-16.js b/tests/uglifyjs/expected/tchwork-16.js
+new file mode 100644
+index 0000000..507b897
+--- /dev/null
++++ b/tests/uglifyjs/expected/tchwork-16.js
+@@ -0,0 +1 @@
++;foo=function n(o,f){n(o+'nnn')};
+diff --git a/tests/uglifyjs/test/mangle.js b/tests/uglifyjs/test/mangle.js
+index c271a26..7371d8e 100644
+--- a/tests/uglifyjs/test/mangle.js
++++ b/tests/uglifyjs/test/mangle.js
+@@ -2,4 +2,5 @@
+ var x = function fun(a, fun, b) {
+ return fun;
+ };
++ x = fun;
+ }());
+diff --git a/tests/uglifyjs/test/tchwork-16.js b/tests/uglifyjs/test/tchwork-16.js
+new file mode 100644
+index 0000000..f2293e3
+--- /dev/null
++++ b/tests/uglifyjs/test/tchwork-16.js
+@@ -0,0 +1,3 @@
++foo = function bar(a, b) {
++ bar(a + "nnn");
++};
diff --git a/php-patchwork-jsqueeze.spec b/php-patchwork-jsqueeze.spec
new file mode 100644
index 0000000..4dd4ab5
--- /dev/null
+++ b/php-patchwork-jsqueeze.spec
@@ -0,0 +1,86 @@
+%global github_owner tchwork
+%global github_name jsqueeze
+%global github_version 2.0.1
+%global github_commit 70a8167daf0e2d5522d5d77a11e3a7d6753683ce
+%global packagist_owner patchwork
+%global packagist_name jsqueeze
+%global psr4_namespace Patchwork
+
+# phpci (uses namespacing)
+%global php_min_ver 5.3.0
+
+Name: php-%{packagist_owner}-%{packagist_name}
+Version: %{github_version}
+Release: 2%{?dist}
+Summary: Efficient JavaScript minification
+
+Group: Development/Libraries
+License: ASL 2.0 or GPLv2
+URL: https://github.com/%{github_owner}/%{github_name}
+# Must use commit-based not tag-based github tarball:
+# https://fedoraproject.org/wiki/Packaging:SourceURL#Github
+Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{github_commit}.tar.gz
+
+# Backported bug fixes
+Patch0: https://github.com/%{github_owner}/%{github_name}/commit/f3747ee91e3025b46e29b2128bbb83f63cbb7f2a.patch
+Patch1: https://github.com/%{github_owner}/%{github_name}/dc3c4073c2060d62a8578848c5d222a8b7608df1.patch
+
+BuildArch: noarch
+# For tests
+BuildRequires: php(language) >= %{php_min_ver}
+BuildRequires: %{_bindir}/phpunit
+
+Requires: php(language) >= %{php_min_ver}
+Requires: php-pcre
+
+Provides: php-composer(%{packagist_owner}/%{packagist_name}) = %{version}
+
+
+%description
+JSqueeze shrinks / compresses / minifies / mangles Javascript code.
+It's a single PHP class that is developed, maintained and thoroughly
+tested since 2003 on major JavaScript frameworks (e.g. jQuery).
+
+JSqueeze operates on any parse error free JavaScript code, even when
+semi-colons are missing.
+
+In term of compression ratio, it compares to YUI Compressor and
+UglifyJS.
+
+
+%prep
+%setup -qn %{github_name}-%{github_commit}
+%patch0 -p1
+%patch1 -p1
+
+
+%build
+# Empty build section, nothing required
+
+
+%install
+# use PSR-0 layout relative to _datadir/php
+mkdir -p %{buildroot}%{_datadir}/php/%{psr4_namespace}
+cp -pr src/* %{buildroot}%{_datadir}/php/%{psr4_namespace}
+
+
+%check
+%{_bindir}/phpunit
+
+
+%files
+%{!?_licensedir:%global license %%doc}
+%license LICENSE.ASL20 LICENSE.GPLv2
+%doc README.md composer.json
+%{_datadir}/php/%{psr4_namespace}
+
+
+%changelog
+* Mon Mar 16 2015 Adam Williamson <awilliam@redhat.com> - 2.0.1-2
+- backport a couple of bugfixes from upstream
+
+* Thu Jan 01 2015 Adam Williamson <awilliam@redhat.com> - 2.0.1-1
+- new release, adjust for upstream PSR-4 layout change, add licenses
+
+* Mon Dec 29 2014 Adam Williamson <awilliam@redhat.com> - 1.0.5-1
+- initial package