cloud-compiler
v1.1.0
Published
App for executing gulp tasks on external machines
Downloads
5
Maintainers
Readme
Cloud Compiler
App is intended to execute custom command line commands(usually compilation related) inside your git repository on external machine which is doing all the compilation heavy lifting and pushing results back to same repo instance inside client machine.
Concept
Cloud compiler is intended to execute time consuming CLI commands like gulp tasks on more powerful server machine. Server machine will execute commands which is setup on gulp file and use git to transfer data back and forth between client machine and server machine.
User of the app will initialize a git repo in directory which contains files to be compiled and gulp file in the root of the directory. Repo will be linked with remote (on Bitbucket, Github or your own git server) and https clone path of the repo will be given to Cloud Compiler.
User will change file which is used as input file of the gulp task and run clcomp compile
command. Client app will git push
the repo to remote , then app server side will git pull
repo from remote to user personal folder in server, server will execute gulp commands in the repo and push compiled repo back to remote, then client app will git pull
compiled repo back.
Therefore client will get compiled files.
The downside of the Cloud Compiler is few seconds time loss for http requests and git operations so you should use it for tasks which takes much more than few seconds ... like minutes or more.
Also all the point of Cloud Compiler is running tasks on server machine more powerful than your working machine to get higher compilation speeds. So if your machine hardware is same of more powerfull then server machine with Cloud Compiler Server there is no point of using it.
But in situation where server compiles at least 2 times faster than your local machine there is a point of using it.
Installation
You need to install cloud compiler globally else it will not be usable:
npm install cloud-compiler -g
Setup
For Cloud Compiler to work you need to setup Cloud Compiler Server on live server machine.
After installation is done first thing to do is configuration file setup.
Config setup
clcfile.js
file is a file which you should create and place under root of local git repo you will use for Cloud Compiler.
You can edit it manually though it's not recomended way to do it. You should use Cloud Compiler command line tools to do that.
Cloud compiler has getter and setter for config options:
Getting config option
clcomp conf get optionName
Setting config option
clcomp conf set optionName optionValue
String values like
watchFor
should be enclosed into quotes like so:clcomp conf set watchFor "sass/**/*.scss"
Required config options
The following options must be correctly set for the app to function correctly:
user
- Your user name on server machine, each user of the app have his own folder in server side which contains repository on which compilations will run.password
- User password on server. Used to confirm that you are the original owner of the folder, without it any user with same name as yours would be able to owerride your repo folder with his. So password is used to avoid conflicts.watchFor
- set of path options to files which you want to watch for changes. Each value can be separated by comma, for example:sass/**/*.scss, scripts/**/*js
. Note that this path is relative to the directory from which you runclcomp
command which is your local repo.serverIP
- public IP address for server machine which is used to run Cloud Compiler ServergitRepoName
- Name of the git repository, for example in this clone pathhttps://Markiyan_Pyts:[email protected]/Markiyan_Pyts/reponame.git
gitRepoName will bereponame
without.git
at the end.serverPort
- Port in server on which the server runs the Cloud Compiler Server by default it's3000
unless you changed it in server.js file on server side.gitClonePath
- HTTPS clone path of repository in which compilations will take place for examplehttps://User_Name:[email protected]/User_Name/reponame.git
It's absolute must to use HTTPS path with password included in example above it's
user_password
, if you use other service than Bitbucket it may have different syntax for including your git password in clone path. Also you should set the same path in you remote option inside your git config file. If you don't follow this advice cloud compiler will not work for you.
gitPushRemote
- Git remote to use in git operations e.gorigin
.gitPushBranch
- Git brunch to use in git operations e.gmaster
.cloudCommands
- Commands to be executed on the server aftercompile
orwatch
command triggers server side compilation. It can be single command likegulp compass
or list of commands separated by commagulp libsass,gulp minify
commands will be executed one by one synchroniously.
Cloud Compiler CLI commands
To run any of clcomp commands you need to
cd
into you local repo directory (directory in which clcfile.js should be created).
clcomp conf reset
- Will reset your clcfile.js , all options will be set to empty string except default server port 3000, git remote "origin" and git branch "master". If you do not have clcfile.js in your repo yet it will be created for you.clcomp init
- Command creates yor folder named by your configuser
option in server side and runsgit clone
of repo specified ingitClonePath
config option inside this folder.clcomp destroy
- Sometimes when you did not setup config options correclly or there was some sort of error duringclcomp init
command andcompile
or newclcomp init
does not workclcomp destroy
will remove your folder and user record on server side. After you can runclcomp init
again.clcomp destroy
works only whenpassword
option in your config matches password for folder owner on server.clcomp compile
- git pushes your local repo to server, runs commands specified incloudCommands
config option one by one and pushes it back to your local repo.clcomp watch
- Watches all files specified inwatchDir
config option and triggersclcomp compile
if files inside changes.
Workflow
To run any of clcomp commands you need to
cd
into you local repo directory (directory in which clcfile.js should be created). In this section this directory is represented in step 1.
- Run
git init
in folder which contains your gulpfile and project files. - Run
git add -A
andgit commit -m ""
in same folder. - Create new repo in https://bitbucket.org and run commands from "I have an existing project" from "Overview" section of new repo in the same folder as above.
- If you plan to use
watch
command setwatchFor
config option. - Set
gitClonePath
config option to the https clone URL of the remote repo you created at step 3. !!!Remember to include your git password inside the clone path you specify and use the same path with password in your local repo git config file after. - Learn your Cloud Compiler Server server machine public IP address and set
serverIP
to it. - Set
cloudCommands
conf option to CLI command you want to run in server side. - Set
user
andpassword
fields as you desire. Note thatuser
name should be unique for each member of your team who use cloud compiler. serverPort
defaults to 3000 don't change it unless you need to.gitPushRemote
defaults toorigin
andgitPushBranch
defaults tomaster
In you want to choose other values for your own workflow you can do it. But defaults should be fine for Cloud Compiler test drive.- Run
clcomp init
and make sure no error occured, if server app is running and you setup config correctly you should getgit clone is done
message in CLI - Now you can run
clcomp compile
or useclcomp watch
command.
Note: Ideally you should init new repo for each person in your team to run compilations in, but alternatively you should be able to just use different branches on the same repo by changing
gitPushBranch
for each of your team members. Of cource every team member should have his ownuser
andpassword
to not override each other compilations.