Skip to content

Commit

Permalink
Merge pull request pro-grid#119 from austinpray/vagrant
Browse files Browse the repository at this point in the history
Added Vagrant Config
  • Loading branch information
austinpray committed Jul 2, 2014
2 parents a8aeff2 + 00ec1e4 commit cc4f7b3
Show file tree
Hide file tree
Showing 14 changed files with 342 additions and 82 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ app/bower_components
.commitdraft
dist/bower_components
*.heapsnapshot
.coveralls.yml
.coveralls.yml
.vagrant
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"quotmark": "true",
"regexp": true,
"undef": true,
"unused": true,
Expand Down
60 changes: 46 additions & 14 deletions CONTRIBUTING.md
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.
27 changes: 24 additions & 3 deletions Makefile
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
71 changes: 11 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,74 +19,21 @@ which handles many clients, and [pro-grid-client][], the user interface built as
a client-side javascript app using [AngularJS][].

## quickstart
This project relies on [Node.js][] and a running [Redis][] instance

Install the dependencies

```bash
npm install
```

Run the server

```bash
# make sure your Redis server is running first
make watch
```

To run the test suite

```bash
make test
```

If you need some help see the getting started tutorial below.

## getting started tutorial

### 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.

Install the Node.js dependencies via
If you know your way around [Vagrant][]:

```bash
npm install
vagrant up
```

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.
For more information on how get up an running and the development environment in
general:

To run the server:

```bash
make watch
```
>[**visit the development instructions**][dev instructions]
This command will do two things:
For a list of commands needed to work on progrid.io server:

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
```
>[**commands reference**][commands link]
If all the tests pass then everything should be good to go at this point.

## team

Expand All @@ -101,6 +48,7 @@ You | Open Sauce Software Contributer
[Bower]: http://bower.io/ "Bower"
[Build Status Badge]: http://img.shields.io/travis/pro-grid/pro-grid.svg?style=flat
[Build Status]: https://travis-ci.org/pro-grid/pro-grid
[CONTRIBUTING.md]: CONTRIBUTING.md
[Code Climate Badge]: http://img.shields.io/codeclimate/github/pro-grid/pro-grid.svg?style=flat
[Code Climate]: https://codeclimate.com/github/pro-grid/pro-grid
[Coverage Status Badge]: https://img.shields.io/coveralls/pro-grid/pro-grid.svg?style=flat
Expand All @@ -116,6 +64,9 @@ You | Open Sauce Software Contributer
[Ruby]: https://www.ruby-lang.org
[Sass]: http://sass-lang.com/ "Sass"
[Socket.IO]: http://socket.io/
[Vagrant]: https://vagrantup.com/
[commands link]: docs/development.md#commands
[dev instructions]: docs/development.md
[devDependency Status Badge]: http://img.shields.io/david/dev/pro-grid/pro-grid.svg?style=flat
[devDependency Status]: https://david-dm.org/pro-grid/pro-grid#info=devDependencies
[gulp]: http://gulpjs.com/ "gulp.js"
Expand Down
35 changes: 35 additions & 0 deletions Vagrantfile
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
100 changes: 100 additions & 0 deletions docs/development.md
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/
4 changes: 4 additions & 0 deletions docs/production.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Deploying progrid.io server to production
===


6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"memory-cache": "0.0.5",
"newrelic": "~1.7.0",
"node-uuid": "~1.4.1",
"randomcolor": "^0.1.1",
"redis": "~0.10.1",
"socket.io": "~1.0.2",
"randomcolor": "^0.1.1",
"validator": "~3.12.0"
},
"devDependencies": {
"coveralls": "~2.10.0",
"gulp": "^3.8.5",
"istanbul": "~0.2.4",
"jshint": "^2.5.1",
"jshint-stylish": "~0.2.0",
"mocha": "~1.20.0",
"mocha-lcov-reporter": "0.0.1",
Expand All @@ -29,7 +29,7 @@
"node": "0.10.x"
},
"scripts": {
"test": "make test",
"test": "./node_modules/.bin/mocha --reporter list",
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
}
}
14 changes: 14 additions & 0 deletions vagrant/README.md
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.

0 comments on commit cc4f7b3

Please sign in to comment.