-
-
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.
- Loading branch information
Showing
6 changed files
with
109 additions
and
1 deletion.
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,24 @@ | ||
How to Contribute | ||
================= | ||
|
||
This project welcomes your contribution. There are several ways to help out: | ||
|
||
* Create an [issue](https://github.com/femtopixel/docker-google-closure-compiler-api/issues/) on GitHub, | ||
if you have found a bug or have an idea for a feature | ||
* Write test cases for open bug issues | ||
* Write patches for open bug/feature issues | ||
|
||
Issues | ||
------ | ||
|
||
* Submit an [issue](https://github.com/femtopixel/docker-google-closure-compiler-api/issues/) | ||
* Make sure it does not already exist. | ||
* Clearly describe the issue including steps to reproduce, when it is a bug. | ||
* Make sure you note the version you use. | ||
|
||
Additional Resources | ||
-------------------- | ||
|
||
* [Existing issues](https://github.com/femtopixel/docker-google-closure-compiler-api/issues/) | ||
* [General GitHub documentation](https://help.github.com/) | ||
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/) |
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,8 @@ | ||
FROM python:alpine | ||
|
||
MAINTAINER Jay MOULIN <jaymoulin@gmail.com> | ||
|
||
COPY ./compiler.py /bin/compiler.py | ||
COPY ./entrypoint.sh /bin/entrypoint | ||
ENTRYPOINT ["/bin/entrypoint"] | ||
CMD ["/bin/compiler.py"] |
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,36 @@ | ||
Google Closure Compiler API - Docker Image | ||
========================================== | ||
|
||
[![latest release](https://img.shields.io/github/release/femtopixel/docker-google-closure-compiler-api.svg "latest release")](http://github.com/femtopixel/docker-google-closure-compiler-api/releases) | ||
[![Bitcoin donation](https://github.com/jaymoulin/jaymoulin.github.io/raw/master/btc.png "Bitcoin donation")](https://m.freewallet.org/id/374ad82e/btc) | ||
[![Litecoin donation](https://github.com/jaymoulin/jaymoulin.github.io/raw/master/ltc.png "Litecoin donation")](https://m.freewallet.org/id/374ad82e/ltc) | ||
|
||
This image allows you to Compile your JS code using [Google Closure Compiler API](https://developers.google.com/closure/compiler/) in CLI | ||
|
||
Usage | ||
----- | ||
``` | ||
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 | ||
------------ | ||
|
||
``` | ||
docker run --rm -ti -v /path/to/my/file.js:/root/myfile.js femtopixel/google-closure-compiler --js /root/myfile.js | ||
``` |
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/local/bin/python3 | ||
|
||
import http.client, urllib.parse, sys, argparse | ||
|
||
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") | ||
args = parser.parse_args() | ||
js_code = open(args.js, 'r') | ||
|
||
params = urllib.parse.urlencode([ | ||
('js_code', js_code.read()), | ||
('compilation_level', args.compilation_level), | ||
('output_format', 'text'), | ||
('output_info', 'compiled_code'), | ||
]) | ||
|
||
js_code.close() | ||
headers = { "Content-type": "application/x-www-form-urlencoded" } | ||
conn = http.client.HTTPConnection('closure-compiler.appspot.com') | ||
conn.request('POST', '/compile', params, headers) | ||
response = conn.getresponse() | ||
data = response.read() | ||
output_code = open(args.js_output_file, 'w') | ||
output_code.write(data.decode("utf-8")) | ||
output_code.close() | ||
conn.close() | ||
|
||
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,8 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
if [ "${1#-}" != "$1" ]; then | ||
set -- /bin/compiler.py "$@" | ||
fi | ||
|
||
exec "$@" |