Compilation as a Service. Instead of having to install node.js to compile LESS files, or Ruby to compile SASS files, now you can just send those files to the cloud and have it compile them for you!
tar -cz in_dir | curl -sfF data=@- http://precomp.ca/sass | tar zxf - -C out_dir/
This will take the contents of in_dir, compress them, send them to the
SASS CaaS, then output the resulting compiled code to out_dir.
The response will be the compiled css files alongside the SASS files.
The client will automatically watch a directory and when anything changes, use the CaaS to compile the changes, and write out the result.
The client is configured using YAML.
key: "s0mek3yh3re"
tasks:
make_css:
compiler: "less"
input: "project/less"
output: "project/css"
extras:
targets: ["main.less", "styles.less"]
logging: off
compile_coffee:
compiler: "coffee"
input: "project/coffee"
output: "project/js"
compile_c:
compiler: "gccmake"
input: "helloworld"
output: "helloworld/bin"
extras:
targets: ['hello.out']- Indentation is important. Use tabs or spaces to indent, but not both.
- The
keyis your unique identification key that can be found on your account page. make_css,compile_coffee, andcompile_care the names of the watch jobs.compileris the type of compiler to use.- The
inputparameter can be a single file or a directory. - The
outputparameter is always treated as a folder. If you only want to output a single file, use the parent directory instead of the filename. - C programs must have a makefile in the project directory.
Key/value pairs under the extras parameter are all optional and differ based on the type of compilation being done.
logging- Setting this tooffwill disable the generation of the__precomp__directory in the output folder.- Type-specific
targetsoverrides:- SAAS and SCSS will by default compile everything in the directory.
Use
targetsto specify which files to compile. - LESS will by default attempt to compile
styles.less. Usetargetsto specify other LESS files. - C compilations will parse the makefile to guess which files to return after compilation.
Use
targetsto specify which files to return after compilation.
- SAAS and SCSS will by default compile everything in the directory.
Use
On every request the client will recieve a string representing the bytes of a compressed file.
Inside the compressed file will be:
- Compiled files. The results of the compilation will be in the root of the compressed file so when extracted, the files go in the specified directory.
- Unless logging has been turned off with the
loggingextra (see above), a folder named__precomp__will be generated. This folder contains a log of any messages the compilation process produced and other data. Useful for debugging.
The status code of the response is the same as usual, except for:
- 400 - This means the complation failed because of an incorrect API call, not a failed compilation.
- 403 - The client failed to provide an authorization key.
- 200 - The compilation was attempted. Compiled files may be in the compressed file.
See the log and
warningHTTP header for more details.
- Create an application on github
- Pick anything for all the fields except the last one.
- set
Authorization callback URLtohttp://localhost:5000/authorized
- Create a database at MongoHQ or any online mongo as a service or run mongo locally.
- Create and activate a Python 3.3+ virtualenv. See virtualenv.org.
- Install requirements with
$ pip install -r requirements-server.txt. - Configure the app. You can either create a
config.pyfile, or export the variables to the environment. You must set these variables:
| Variable | Description |
|---|---|
SECRET_KEY |
Must be something, but for local development it can be anything |
DEBUG |
You'll probably want this to be True for local development |
GITHUB_CLIENT_ID |
GitHub gives you this after registering your application on GitHub |
GITHUB_CLIENT_SECRET |
Same deal |
MONGO_URI |
Whatever you got from MongoHQ or wherever. |
DO_CLIENT_ID |
Your Digital Ocean client ID. |
DO_API_KEY |
Your Digital Ocean API key. |
After these steps, you should be able to just:
(venv) $ python manage.py runserverand play around at localhost:5000