-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3 - add google_closure_compiler_api pypi module
- Loading branch information
Showing
11 changed files
with
191 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build | ||
google_closure_compiler_api.egg-info | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.PHONY: install clean check | ||
|
||
test: | ||
make install | ||
twine upload -r testpypi dist/* | ||
publish: | ||
make install | ||
twine upload dist/* | ||
install: | ||
make clean | ||
make check | ||
sudo python3 setup.py sdist | ||
check: | ||
python3 setup.py check --restructuredtext | ||
build: | ||
mkdir -p build | ||
dist: | ||
mkdir -p dist | ||
clean: build dist | ||
sudo rm -Rf build/* | ||
sudo rm -Rf dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
========================================== | ||
Google Closure Compiler API - Docker Image | ||
========================================== | ||
|
||
.. image:: https://img.shields.io/github/release/femtopixel/docker-google-closure-compiler-api.svg | ||
:alt: latest release | ||
:align: left | ||
:target: http://github.com/femtopixel/docker-google-closure-compiler-api/releases | ||
.. image:: https://img.shields.io/pypi/v/google-closure-compiler-api.svg | ||
:alt: PyPI version | ||
:align: left | ||
:target: https://pypi.python.org/pypi?:action=display&name=google-closure-compiler-api | ||
.. image:: https://img.shields.io/docker/pulls/femtopixel/google-closure-compiler.svg | ||
:align: left | ||
:target: https://hub.docker.com/r/femtopixel/google-closure-compiler/ | ||
.. image:: https://img.shields.io/docker/stars/femtopixel/google-closure-compiler.svg | ||
:align: left | ||
:target: https://hub.docker.com/r/femtopixel/google-closure-compiler/ | ||
.. image:: https://img.shields.io/docker/pulls/femtopixel/google-closure-compiler-app.svg | ||
:align: left | ||
:target: https://hub.docker.com/r/femtopixel/google-closure-compiler-app/ | ||
.. image:: https://img.shields.io/docker/stars/femtopixel/google-closure-compiler-app.svg | ||
:align: left | ||
:target: https://hub.docker.com/r/femtopixel/google-closure-compiler-app/ | ||
.. image:: https://github.com/jaymoulin/jaymoulin.github.io/raw/master/btc.png | ||
:alt: Bitcoin donation | ||
:align: left | ||
:target: https://m.freewallet.org/id/374ad82e/btc | ||
.. image:: https://github.com/jaymoulin/jaymoulin.github.io/raw/master/ltc.png | ||
:alt: Litecoin donation | ||
:align: left | ||
:target: https://m.freewallet.org/id/374ad82e/ltc | ||
.. image:: https://github.com/jaymoulin/jaymoulin.github.io/raw/master/ppl.png | ||
:alt: PayPal donation | ||
:align: left | ||
:target: https://www.paypal.me/jaymoulin | ||
.. image:: https://beerpay.io/femtopixel/docker-google-closure-compiler-api/badge.svg | ||
:alt: Beerpay donation | ||
:align: left | ||
:target: https://beerpay.io/femtopixel/docker-google-closure-compiler-api | ||
|
||
This image allows you to Compile your JS code using `Google Closure Compiler API <https://developers.google.com/closure/compiler/>`_ in CLI | ||
|
||
Install | ||
======= | ||
|
||
.. code:: | ||
pip3 install google_closure_compiler_api | ||
Usage | ||
===== | ||
.. code:: | ||
usage: compiler.py [-h] [--js JS] [--js_output_file JS_OUTPUT_FILE] [--compilation_level {WHITESPACE_ONLY,SIMPLE_OPTIMIZATIONS,ADVANCED_OPTIMIZATIONS}] | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
--js JS Input file | ||
--js_output_file JS_OUTPUT_FILE | ||
Output file | ||
--compilation_level {WHITESPACE_ONLY,SIMPLE_OPTIMIZATIONS,ADVANCED_OPTIMIZATIONS} | ||
Compilation level | ||
Default values | ||
-------------- | ||
|
||
- `--js` : /dev/stdin (input your code) | ||
- `--js_output_file` : /dev/stdout (Prints compiled code in the shell) | ||
- `--compilation_level` : WHITESPACE_ONLY | ||
|
||
Docker usage | ||
============ | ||
|
||
.. code:: | ||
docker run --rm -ti -v /path/to/my/file.js:/root/myfile.js femtopixel/google-closure-compiler --js /root/myfile.js | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
""" | ||
""" | ||
|
||
from .compiler import compile_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
|
||
import http.client | ||
import urllib.parse | ||
import argparse | ||
|
||
__all__ = ['compile_file'] | ||
|
||
|
||
def compile_file(input_file='/dev/stdin', out='/dev/stdout', level='WHITESPACE_ONLY', external=''): | ||
js_code = open(input_file, 'r') | ||
|
||
params = urllib.parse.urlencode([ | ||
('js_code', js_code.read()), | ||
('compilation_level', level), | ||
('output_format', 'text'), | ||
('output_info', 'compiled_code'), | ||
('js_externs', external), | ||
]) | ||
|
||
js_code.close() | ||
headers = {"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"} | ||
conn = http.client.HTTPSConnection('closure-compiler.appspot.com') | ||
conn.request('POST', '/compile', params, headers) | ||
response = conn.getresponse() | ||
data = response.read() | ||
output_code = open(out, 'w') | ||
output_code.write(data.decode("utf-8")) | ||
output_code.close() | ||
conn.close() | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--js", default='/dev/stdin', help="Input file") | ||
parser.add_argument("--js_output_file", default='/dev/stdout', help="Output file") | ||
parser.add_argument("--compilation_level", default='WHITESPACE_ONLY', | ||
choices=['WHITESPACE_ONLY', 'SIMPLE_OPTIMIZATIONS', 'ADVANCED_OPTIMIZATIONS'], | ||
help="Compilation level") | ||
parser.add_argument("--js_externs", default='', | ||
help="Declare some external js vars and functions separated with semicolon") | ||
args = parser.parse_args() | ||
compile_file(args.js, args.js_output_file, args.compilation_level, args.js_externs) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='google_closure_compiler_api', | ||
python_requires=">=3", | ||
version='0.1.4', | ||
packages=find_packages(), | ||
long_description=open("README.rst", 'r').read(), | ||
author="Jay MOULIN", | ||
author_email="jaymoulin@gmail.com", | ||
description="Google closure compiler CLI API", | ||
include_package_data=True, | ||
url='http://github.com/femtopixel/docker-google-closure-compiler-api', | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"Programming Language :: Python", | ||
"License :: OSI Approved :: MIT License", | ||
"Natural Language :: English", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Topic :: Multimedia :: Sound/Audio", | ||
], | ||
entry_points={ | ||
'console_scripts': [ | ||
'google-closure-compiler = google_closure_compiler_api.compiler:main', | ||
], | ||
}, | ||
license="MIT", | ||
) |