This is proof of concept of Webtask Everywhere working purely on server, with minor changes. It uses Babel 5 at the moment, and can compile modules with relatively shallow dependencies for webtask on webtask. So in short this is a webtask that creates webtask on webtask. This was deployed to webtask using itself!
If you haven't checked out webtask, do it! It is incredible :D
path: /compile/
method: GET
params:
src : Github or Gitlab url
type: 'repo'
Note: Your package.json needs an x-webtask
field set for the origin of your webtask, or this will just use the file linked at main
or /index.js
in the source repository.
- Add a badge to your git repository with webtask code that lets a user deploy this code to their own tenant.
- Add this as a git-hook and let a webtask build your webtask on a git push.
Modules with extremely deep dependency trees will not compile. It hits the 35 second time limit, but only when this is running on webtask. (So for instance don't have babel 6 or any of cousins in your direct dependencies (its fine to have it in devDependencies) or use babel version from the server you can find out the versions of dependencies present already in the sandbox here.
- The task creates a unqiue directory in
/tmp
- It fetches the git repository using archived.zip (Geit fails on node 0.12.6 :-/ or else I would have used geit clone --- geit is an smart-http client for git that runs in node)
- It reads the package json and figures out the dependencies that will be missing in the sandbox.
- Installs only the missing dependencies.
- Runs browserify with sandbox dependencies as externals.
- Transpiles the code using babel 5.
- Uglifies and minifies the output.
- Sends back the package to you.
- You can create a webtask using the file.
- You deploy it using webtask cli.
I originally wanted to use plivo for an example to learn using webtask, and didn't find it in the sandbox. So I thought how cool would it be to have a webtask that compiles webtask in the webtask environment. This built itself as well as Plivo Example. While doing this I learnt a lot about webtask and its environment. Essentially this was hacked in 2 days (or late coffee filled eye soring nights)!
- An interface.
- Zip and Direct file support.