Bug 1388013 - Vendor jsmin via |mach vendor python|; r=ahal
☠☠ backed out by ba9528133000 ☠ ☠
authorDave Hunt <dhunt@mozilla.com>
Wed, 30 May 2018 13:07:32 +0100
changeset 420724 3a163da2b21b5b835c6a0e41cd0d35425cc84edb
parent 420723 86af7f209e195f83d60f2729ff817f29075289ca
child 420725 c55bfefbd4e1786bd90ed173bbef547dff8d84ef
push id103885
push usernerli@mozilla.com
push dateThu, 31 May 2018 21:59:32 +0000
treeherdermozilla-inbound@731cfcb5e07c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1388013
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1388013 - Vendor jsmin via |mach vendor python|; r=ahal MozReview-Commit-ID: 197reaD9GdL
Pipfile
Pipfile.lock
third_party/python/jsmin/LICENSE.txt
third_party/python/jsmin/MANIFEST.in
third_party/python/jsmin/PKG-INFO
third_party/python/jsmin/README.rst
third_party/python/jsmin/jsmin/__init__.py
third_party/python/jsmin/jsmin/__main__.py
third_party/python/jsmin/jsmin/test.py
--- a/Pipfile
+++ b/Pipfile
@@ -6,11 +6,12 @@ name = "pypi"
 [dev-packages]
 
 [packages]
 pipenv = "==2018.5.18"
 virtualenv = "==15.2.0"
 six = "==1.10.0"
 attrs = "==18.1.0"
 pytest = "==3.2.5"
+jsmin = "==2.0.11"
 
 [requires]
 python_version = "2.7"
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,12 +1,12 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "cfd63f783e0107d8c5ebc5f17ee5c6644825657a4504e5529ceaabb293837659"
+            "sha256": "4b5d386952702feee696b0166421981cae6fad8c96b233923e0343095c38903e"
         },
         "pipfile-spec": 6,
         "requires": {
             "python_version": "2.7"
         },
         "sources": [
             {
                 "name": "pypi",
@@ -26,16 +26,23 @@
         },
         "certifi": {
             "hashes": [
                 "sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7",
                 "sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0"
             ],
             "version": "==2018.4.16"
         },
+        "jsmin": {
+            "hashes": [
+                "sha256:7898a19e17a89b1e294cce4a43b107441630eeacae4cf9595961eb39e1a716d1"
+            ],
+            "index": "pypi",
+            "version": "==2.0.11"
+        },
         "pipenv": {
             "hashes": [
                 "sha256:04b9a8b02a3ff12a5502b335850cfdb192adcfd1d6bbdb7a7c47cae9ab9ddece",
                 "sha256:e96d5bfa6822a17b2200d455aa5f9002c14361c50df1b1e51921479d7c09e741"
             ],
             "index": "pypi",
             "version": "==2018.5.18"
         },
new file mode 100644
--- /dev/null
+++ b/third_party/python/jsmin/LICENSE.txt
@@ -0,0 +1,23 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Dave St.Germain
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
new file mode 100644
--- /dev/null
+++ b/third_party/python/jsmin/MANIFEST.in
@@ -0,0 +1,1 @@
+include *.txt
new file mode 100644
--- /dev/null
+++ b/third_party/python/jsmin/PKG-INFO
@@ -0,0 +1,92 @@
+Metadata-Version: 1.1
+Name: jsmin
+Version: 2.0.11
+Summary: JavaScript minifier.
+PLEASE UPDATE TO VERSION >= 2.0.6. Older versions have a serious bug related to comments.
+Home-page: https://bitbucket.org/dcs/jsmin/
+Author: Tikitu de Jager
+Author-email: tikitu+jsmin@logophile.org
+License: MIT License
+Description: =====
+        jsmin
+        =====
+        
+        JavaScript minifier.
+        
+        Usage
+        =====
+        
+        .. code:: python
+        
+         from jsmin import jsmin
+         with open('myfile.js') as js_file:
+             minified = jsmin(js_file.read())
+        
+        You can run it as a commandline tool also::
+        
+          python -m jsmin myfile.js
+        
+        Where to get it
+        ===============
+        
+        * install the package `from pypi <https://pypi.python.org/pypi/jsmin/>`_
+        * get the latest release `from the stable branch on bitbucket <https://bitbucket.org/dcs/jsmin/branch/stable>`_
+        * get the development version `from the default branch on bitbucket <https://bitbucket.org/dcs/jsmin/branch/default>`_
+        
+        Contributing
+        ============
+        
+        `Issues <https://bitbucket.org/dcs/jsmin/issues>`_ and `Pull requests <https://bitbucket.org/dcs/jsmin/pull-requests>`_
+        will be gratefully received on Bitbucket. Pull requests on github are great too, but the issue tracker lives on
+        bitbucket.
+        
+        If possible, please make separate pull requests for tests and for code: tests will be committed on the stable branch
+        (which tracks the latest released version) while code will go to default by, erm, default.
+        
+        Unless you request otherwise, your Bitbucket identity will be added to the contributor's list below; if you prefer a
+        different name feel free to add it in your pull request instead. (If you prefer not to be mentioned you'll have to let
+        the maintainer know somehow.)
+        
+        Build/test status
+        =================
+        
+        Both default and stable branches are tested with Travis: https://travis-ci.org/tikitu/jsmin
+        
+        Stable (latest released version plus any new tests) is tested against CPython 2.6, 2.7, 3.2, and 3.3.
+        Currently:
+        
+        .. image:: https://travis-ci.org/tikitu/jsmin.png?branch=ghstable
+        
+        If stable is failing that means there's a new test that fails on *the latest released version on pypi*, with no fix yet
+        released.
+        
+        Default (development version, might be ahead of latest released version) is tested against CPython 2.6, 2.7, 3.2, and
+        3.3. Currently:
+        
+        .. image:: https://travis-ci.org/tikitu/jsmin.png?branch=master
+        
+        If default is failing don't use it, but as long as stable is passing the pypi release should be ok.
+        
+        Contributors (chronological commit order)
+        =========================================
+        
+        * `Dave St.Germain <https://bitbucket.org/dcs>`_ (original author)
+        * `Hans weltar <https://bitbucket.org/hansweltar>`_
+        * `Tikitu de Jager <mailto:tikitu+jsmin@logophile.org>`_ (current maintainer)
+        * https://bitbucket.org/rennat
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Web Environment
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
+Classifier: Topic :: Software Development :: Pre-processors
+Classifier: Topic :: Text Processing :: Filters
new file mode 100644
--- /dev/null
+++ b/third_party/python/jsmin/README.rst
@@ -0,0 +1,67 @@
+=====
+jsmin
+=====
+
+JavaScript minifier.
+
+Usage
+=====
+
+.. code:: python
+
+ from jsmin import jsmin
+ with open('myfile.js') as js_file:
+     minified = jsmin(js_file.read())
+
+You can run it as a commandline tool also::
+
+  python -m jsmin myfile.js
+
+Where to get it
+===============
+
+* install the package `from pypi <https://pypi.python.org/pypi/jsmin/>`_
+* get the latest release `from the stable branch on bitbucket <https://bitbucket.org/dcs/jsmin/branch/stable>`_
+* get the development version `from the default branch on bitbucket <https://bitbucket.org/dcs/jsmin/branch/default>`_
+
+Contributing
+============
+
+`Issues <https://bitbucket.org/dcs/jsmin/issues>`_ and `Pull requests <https://bitbucket.org/dcs/jsmin/pull-requests>`_
+will be gratefully received on Bitbucket. Pull requests on github are great too, but the issue tracker lives on
+bitbucket.
+
+If possible, please make separate pull requests for tests and for code: tests will be committed on the stable branch
+(which tracks the latest released version) while code will go to default by, erm, default.
+
+Unless you request otherwise, your Bitbucket identity will be added to the contributor's list below; if you prefer a
+different name feel free to add it in your pull request instead. (If you prefer not to be mentioned you'll have to let
+the maintainer know somehow.)
+
+Build/test status
+=================
+
+Both default and stable branches are tested with Travis: https://travis-ci.org/tikitu/jsmin
+
+Stable (latest released version plus any new tests) is tested against CPython 2.6, 2.7, 3.2, and 3.3.
+Currently:
+
+.. image:: https://travis-ci.org/tikitu/jsmin.png?branch=ghstable
+
+If stable is failing that means there's a new test that fails on *the latest released version on pypi*, with no fix yet
+released.
+
+Default (development version, might be ahead of latest released version) is tested against CPython 2.6, 2.7, 3.2, and
+3.3. Currently:
+
+.. image:: https://travis-ci.org/tikitu/jsmin.png?branch=master
+
+If default is failing don't use it, but as long as stable is passing the pypi release should be ok.
+
+Contributors (chronological commit order)
+=========================================
+
+* `Dave St.Germain <https://bitbucket.org/dcs>`_ (original author)
+* `Hans weltar <https://bitbucket.org/hansweltar>`_
+* `Tikitu de Jager <mailto:tikitu+jsmin@logophile.org>`_ (current maintainer)
+* https://bitbucket.org/rennat
--- a/third_party/python/jsmin/jsmin/__init__.py
+++ b/third_party/python/jsmin/jsmin/__init__.py
@@ -35,45 +35,44 @@ else:
     except ImportError:
         cStringIO = None
 
 
 __all__ = ['jsmin', 'JavascriptMinify']
 __version__ = '2.0.11'
 
 
-def jsmin(js, **kwargs):
+def jsmin(js):
     """
     returns a minified version of the javascript string
     """
     if not is_3:        
         if cStringIO and not isinstance(js, unicode):
             # strings can use cStringIO for a 3x performance
             # improvement, but unicode (in python2) cannot
             klass = cStringIO.StringIO
         else:
             klass = StringIO.StringIO
     else:
         klass = io.StringIO
     ins = klass(js)
     outs = klass()
-    JavascriptMinify(ins, outs, **kwargs).minify()
+    JavascriptMinify(ins, outs).minify()
     return outs.getvalue()
 
 
 class JavascriptMinify(object):
     """
     Minify an input stream of javascript, writing
     to an output stream
     """
 
-    def __init__(self, instream=None, outstream=None, quote_chars="'\""):
+    def __init__(self, instream=None, outstream=None):
         self.ins = instream
         self.outs = outstream
-        self.quote_chars = quote_chars
 
     def minify(self, instream=None, outstream=None):
         if instream and outstream:
             self.ins, self.outs = instream, outstream
         
         self.is_return = False
         self.return_buf = ''
         
@@ -86,17 +85,17 @@ class JavascriptMinify(object):
             self.outs.write(char)
             if self.is_return:
                 self.return_buf = ''
 
         read = self.ins.read
 
         space_strings = "abcdefghijklmnopqrstuvwxyz"\
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$\\"
-        starters, enders = '{[(+-', '}])+-' + self.quote_chars
+        starters, enders = '{[(+-', '}])+-"\''
         newlinestart_strings = starters + space_strings
         newlineend_strings = enders + space_strings
         do_newline = False
         do_space = False
         escape_slash_count = 0
         doing_single_comment = False
         previous_before_comment = ''
         doing_multi_comment = False
@@ -116,17 +115,17 @@ class JavascriptMinify(object):
                 previous = next1
                 next1 = read(1)
             else:
                 in_re = True  # literal regex at start of script
                 write(previous)
         elif not previous:
             return
         elif previous >= '!':
-            if previous in self.quote_chars:
+            if previous in "'\"":
                 in_quote = previous
             write(previous)
             previous_non_space = previous
         else:
             previous_non_space = ' '
         if not next1:
             return
 
@@ -215,19 +214,19 @@ class JavascriptMinify(object):
                     write('/')
             else:
                 if do_space:
                     do_space = False
                     write(' ')
                 if do_newline:
                     write('\n')
                     do_newline = False
-
+                    
                 write(next1)
-                if not in_re and next1 in self.quote_chars:
+                if not in_re and next1 in "'\"":
                     in_quote = next1
                     quote_buf = []
 
             previous = next1
             next1 = next2
 
             if previous >= '!':
                 previous_non_space = previous
new file mode 100644
--- /dev/null
+++ b/third_party/python/jsmin/jsmin/__main__.py
@@ -0,0 +1,10 @@
+import sys, os, glob
+from jsmin import JavascriptMinify
+
+for f in sys.argv[1:]:
+    with open(f, 'r') as js:
+        minifier = JavascriptMinify(js, sys.stdout)
+        minifier.minify()
+    sys.stdout.write('\n')
+    
+    
--- a/third_party/python/jsmin/jsmin/test.py
+++ b/third_party/python/jsmin/jsmin/test.py
@@ -7,18 +7,18 @@ class JsTests(unittest.TestCase):
         return jsmin.jsmin(js)
 
     def assertEqual(self, thing1, thing2):
         if thing1 != thing2:
             print(repr(thing1), repr(thing2))
             raise AssertionError
         return True
     
-    def assertMinified(self, js_input, expected, **kwargs):
-        minified = jsmin.jsmin(js_input, **kwargs)
+    def assertMinified(self, js_input, expected):
+        minified = jsmin.jsmin(js_input)
         assert minified == expected, "%r != %r" % (minified, expected)
         
     def testQuoted(self):
         js = r'''
         Object.extend(String, {
           interpret: function(value) {
             return value == null ? '' : String(value);
           },
@@ -342,53 +342,14 @@ var  foo    =  "hey";
         expected = 'var msie;'
         self.assertMinified(original, expected)
 
     def test_angular_4(self):
         original = 'var /* comment */ msie;'
         expected = 'var msie;'
         self.assertMinified(original, expected)
 
-    def test_angular_5(self):
+    def test_angular_4(self):
         original = 'a/b'
         self.assertMinified(original, original)
 
-    def testBackticks(self):
-        original = '`test`'
-        self.assertMinified(original, original, quote_chars="'\"`")
-
-        original = '` test with leading whitespace`'
-        self.assertMinified(original, original, quote_chars="'\"`")
-
-        original = '`test with trailing whitespace `'
-        self.assertMinified(original, original, quote_chars="'\"`")
-
-        original = '''`test
-with a new line`'''
-        self.assertMinified(original, original, quote_chars="'\"`")
-
-        original = '''dumpAvStats: function(stats) {
-        var statsString = "";
-        if (stats.mozAvSyncDelay) {
-          statsString += `A/V sync: ${stats.mozAvSyncDelay} ms `;
-        }
-        if (stats.mozJitterBufferDelay) {
-          statsString += `Jitter-buffer delay: ${stats.mozJitterBufferDelay} ms`;
-        }
-
-        return React.DOM.div(null, statsString);'''
-        expected = 'dumpAvStats:function(stats){var statsString="";if(stats.mozAvSyncDelay){statsString+=`A/V sync: ${stats.mozAvSyncDelay} ms `;}\nif(stats.mozJitterBufferDelay){statsString+=`Jitter-buffer delay: ${stats.mozJitterBufferDelay} ms`;}\nreturn React.DOM.div(null,statsString);'
-        self.assertMinified(original, expected, quote_chars="'\"`")
-
-    def testBackticksExpressions(self):
-        original = '`Fifteen is ${a + b} and not ${2 * a + b}.`'
-        self.assertMinified(original, original, quote_chars="'\"`")
-
-        original = '''`Fifteen is ${a +
-b} and not ${2 * a + "b"}.`'''
-        self.assertMinified(original, original, quote_chars="'\"`")
-
-    def testBackticksTagged(self):
-        original = 'tag`Hello ${ a + b } world ${ a * b}`;'
-        self.assertMinified(original, original, quote_chars="'\"`")
-
 if __name__ == '__main__':
     unittest.main()