forked from pro-grid/pro-grid
-
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.
Merge pull request pro-grid#119 from austinpray/vagrant
Added Vagrant Config
- Loading branch information
Showing
14 changed files
with
342 additions
and
82 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 |
---|---|---|
|
@@ -5,4 +5,5 @@ app/bower_components | |
.commitdraft | ||
dist/bower_components | ||
*.heapsnapshot | ||
.coveralls.yml | ||
.coveralls.yml | ||
.vagrant |
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 |
---|---|---|
@@ -1,19 +1,51 @@ | ||
progrid.io | ||
Contributing to progrid.io server | ||
=== | ||
## Javascript Guidelines | ||
We appreciate all pull requests. However in an effort to keep the code maintainable we do ask that potential contributions follow some style guidelines. When in doubt, I would default to the [Google JavaScript Style Guide](https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml). | ||
## development environment | ||
|
||
### All code should pass [JSHint](http://www.jshint.com/) without errors | ||
run `grunt jshint` to check your build for [JSHint](http://www.jshint.com/) errors. This helps easily enforce best practices across all contributions. | ||
>JSHint is a community-driven tool to detect errors and potential problems in JavaScript code and to enforce your team's coding conventions. It is very flexible so you can easily adjust it to your particular coding guidelines and the environment you expect your code to execute in. JSHint is open source and will always stay this way. | ||
## vagrant development getting started tutorial | ||
|
||
### Asynchronous style | ||
If you would like to make improvements to web.js (the node server componenet), we are trying to minimize the amount of synchronous code. Please consider writing in an asynchronous style when modifying web.js. | ||
## local development getting started tutorial | ||
|
||
**More information:** | ||
- http://blog.shinetech.com/2011/08/26/asynchronous-code-design-with-node-js/ | ||
- https://github.com/caolan/async#asyncjs | ||
- http://book.mixu.net/node/ch7.html | ||
### install dependencies | ||
We presume you have an up-to-date version of [Node.js][] installed on your machine. | ||
We recommend [nvm][] for managing your node installations. | ||
|
||
### We agile now | ||
Austin is the scrum master or whatever | ||
Install the Node.js dependencies via | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
Progrid uses [Redis][] as its data store. You will need to install and run a | ||
Redis server to run the progrid server. Installation instructions can | ||
be found [here][Redis install]. If you are on a Mac with [Homebrew][] installed it | ||
is as simple as running `brew install redis` and following the post-install | ||
instructions. | ||
|
||
### run the server | ||
We use [Make][] as our build tool. Most all unix-like operating systems should | ||
have this utility out of the box. | ||
|
||
To run the server: | ||
|
||
```bash | ||
make watch | ||
``` | ||
|
||
This command will do two things: | ||
|
||
1. Run `lib/web.js` which will start the server | ||
2. Restart the server any time you change the source files | ||
|
||
This makes development nice and easy. | ||
|
||
Note: if you do not have Make (perhaps you are on Windows) and are truly lazy, | ||
you can manually copy/paste the commands found in the [Makefile][] | ||
|
||
### run the test suite | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
If all the tests pass then everything should be good to go at this point. |
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 |
---|---|---|
@@ -1,7 +1,28 @@ | ||
PG_BUILD_DIR=/var/local/www | ||
PG_EXEC=vagrant ssh -c | ||
PG_SYNC=vagrant rsync | ||
PG_VAGRANT=$(PG_EXEC) | ||
PG_CD=cd $(PG_BUILD_DIR) && | ||
|
||
sync: | ||
$(PG_SYNC) | ||
|
||
watch: | ||
./node_modules/.bin/nodemon lib/web.js | ||
vagrant up | ||
|
||
test: | ||
./node_modules/.bin/mocha --reporter list | ||
$(PG_VAGRANT) "$(PG_CD) npm test" | ||
|
||
logs: | ||
$(PG_VAGRANT) 'tail -f -n 20 /var/log/node.log' | ||
|
||
jshint: | ||
$(PG_VAGRANT) '$(PG_CD) ./node_modules/jshint/bin/jshint --reporter node_modules/jshint-stylish/stylish.js lib/*.js test/*.js' | ||
|
||
install: sync | ||
$(PG_VAGRANT) '$(PG_CD) npm prune && npm install' | ||
|
||
destoroyah: | ||
vagrant destroy -f && vagrant up | ||
|
||
.PHONY: test watch | ||
.PHONY: test watch jshint install sync |
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,35 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
config.vm.box = "ubuntu/trusty64" | ||
|
||
config.vm.network "forwarded_port", guest: 9001, host: 9001 | ||
|
||
build_path = "/var/local/www" | ||
|
||
config.vm.synced_folder ".", build_path, type: "rsync", | ||
rsync__exclude: [ | ||
".git/", | ||
"lib/", | ||
"site/", | ||
"test/", | ||
"node_modules", | ||
"vendor/", | ||
".heroku", | ||
".profile.d" | ||
] | ||
config.vm.synced_folder "lib/", build_path+"/lib" | ||
config.vm.synced_folder "site/", build_path+"/site" | ||
config.vm.synced_folder "test/", build_path+"/test" | ||
|
||
config.vm.provision "shell", | ||
path: "./vagrant/install.sh", | ||
args: build_path, | ||
keep_color: true | ||
|
||
config.vm.provision "shell", inline: "initctl start pro-grid", run: "always" | ||
|
||
end |
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,100 @@ | ||
Developing progrid.io server | ||
=== | ||
|
||
![development gif][] | ||
|
||
## summary | ||
progrid.io server has a pretty slick Vagrant-based development environment | ||
packaged and ready to go. | ||
[Learn more about how Vagrant benefits you.][Why Vagrant] | ||
|
||
## dependencies | ||
progrid.io server has a pretty slick development environment packaged and | ||
ready to go. You need these things installed on your machine to get started: | ||
|
||
- [Vagrant][] | ||
- [Virtualbox][] | ||
- [Make][] (included by default in any Unix-like OS) | ||
|
||
## get started | ||
To spawn a fully-functioning development environment all you have to do is run: | ||
|
||
```bash | ||
# inside the project directory | ||
vagrant up | ||
``` | ||
|
||
This gives you an Ubuntu 14.04 LTS guest machine with | ||
|
||
- [Node.JS][] and [npm][] | ||
- [Redis][] | ||
- progrid.io server running at http://localhost:9001 | ||
|
||
Your entire project directory is rsynced one time to the guest machine. Changes | ||
to the following folders are updated live on the guest machine as you work on | ||
them: | ||
|
||
- `lib/` | ||
- `test/` | ||
- `site/` | ||
|
||
Every time you change a file in `lib/`, the progrid.io server process is | ||
automatically restarted | ||
|
||
## commands | ||
All commands are run inside the project directory. Refer to the [Vagrant | ||
Command-Line Interface Documentation][Vagrant CLI Docs] full a full list of | ||
Vagrant commands. | ||
|
||
### vagrant up | ||
spawns vagrant development environment | ||
|
||
### vagrant destroy | ||
completely deletes your vagrant development environment and cleans up after | ||
itself | ||
|
||
### vagrant ssh | ||
run commands inside the guest machine | ||
|
||
### make install | ||
Every time you modify the package.json and change progrid.io server’s | ||
dependencies, you must update the guest machine’s slug with `make install`. This | ||
command will: | ||
|
||
1. use rsync to sync the new package.json with the updated list of | ||
dependencies to the guest machine. | ||
2. `npm prune` to get rid of any unused dependencies. | ||
3. `npm install` to install any new dependencies. | ||
|
||
### make logs | ||
Live `tail` of the server log files. Useful for debugging purposes. Logs are | ||
located at `var/log/node.log` on the guest machine FYI. | ||
|
||
### make test | ||
runs progrid.io server’s [Mocha][] test suite. | ||
|
||
### make jshint | ||
runs [JSHint][] on the .js files inside `lib/` and `test/`. | ||
|
||
### make sync | ||
Any time you make edits outside of `lib/`, `test/`, or `site/` you must sync | ||
these changes over to the guest machine. You will not have to use this command | ||
very often however. | ||
|
||
## need help? | ||
[Opening an issue][new issue] is the fastest way to get help. You can also try | ||
pinging Austin Pray ([@austinpray][]) on Twitter. | ||
|
||
[@austinpray]: https://twitter.com/austinpray | ||
[JSHint]: http://www.jshint.com/ | ||
[Make]: http://www.gnu.org/software/make/ | ||
[Mocha]: http://visionmedia.github.io/mocha/ | ||
[Node.JS]: http://nodejs.org/ | ||
[Redis]: http://redis.io/ | ||
[Vagrant CLI Docs]: http://docs.vagrantup.com/v2/cli/index.html | ||
[Vagrant]: https://docs.vagrantup.com/v2/installation/index.html | ||
[Virtualbox]: https://www.virtualbox.org/wiki/Downloads | ||
[Why Vagrant]: http://docs.vagrantup.com/v2/why-vagrant/index.html | ||
[development gif]: http://i.imgur.com/OnoxXgq.gif | ||
[new issue]: https://github.com/pro-grid/pro-grid/issues/new | ||
[npm]: https://www.npmjs.org/ |
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,4 @@ | ||
Deploying progrid.io server to production | ||
=== | ||
|
||
|
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,14 @@ | ||
Provisioning Directory | ||
=== | ||
|
||
This directory is full of goodies that will help you provision and run a vagrant | ||
instance running the pro-grid server and all the dependencies. | ||
|
||
run | ||
|
||
```bash | ||
vagrant up | ||
``` | ||
|
||
and then visit `localhost:9001` and you should see the pro-grid server welcome | ||
page. |
Oops, something went wrong.