Skip to content

Latest commit

 

History

History
124 lines (83 loc) · 4.13 KB

File metadata and controls

124 lines (83 loc) · 4.13 KB

Development

Note: These instructions were written with a Linux system in mind. It should also work on OS X, but has not been tested on Windows. Windows users can ignore all the sudo keywords.

Prerequisites

Dependencies

To install the Node.js dependencies and the SCSS preprocessor, run (from the root of the repo directory):

sudo npm install
sudo npm install -g sails
sudo npm install -g sails-migrations
sudo npm install -g nodemon
gem install sass

The -g flag installs the packages globally, so you can easily access them.

Configure PostgreSQL

Note: You'll need PostgreSQL 9.3.x. If you happen to be on Elementary OS, you can install it by following these instructions.

First, we need to configure PostgreSQL properly. Edit the pg_hba.conf file in /etc/postgresql/9.3/main so that the line that says

local   all             postgres                                peer

says

local   all             postgres                                md5

Then, restart Postgres by running:

sudo service postgresql restart

You should then be able to enter a psql console by running psql --username=postgres.

Migrate the database

We are using barrels to load fixtures from test/fixtures. The data is automatically loaded every time the server is launched (lifted). You will be prompted to choose how the tables/collections/sets are migrated (not migrated, attempt to keep existing data, or drop and rebuild).

You will need to change the password for the postgres user first to ensure it matches the configuration settings:

psql -U postgres -c "ALTER USER postgres PASSWORD 'postgres';"

To initialize the database:

sails-migrations db:create

or

createdb -U postgres ittybitty_dev

To drop the database, you could do it manually in psql or run:

sails-migrations db:drop

We are using sails-migrations for database migrations and sails-postgresql as the adapter.

Running locally

Start a local server by running:

sails lift

You can then view the web app in your browser at http://localhost:1337/ (or http://0.0.0.0:1337/).

Watching for changes

If you're making changes to the code often and want to see the changes more or less immediately in your browser, you can use nodemon instead of running the regular sails lift. To run the application through nodemon while watching the directory contents, make sure you're in the root of this repo directory and run:

nodemon --watch app

You can view it in your browser at the usual location (port 1337). Any changes made to the core configuration of the app (e.g. anything in the config directory) will require you to manually restart the server, which can be done by typing rs.

Debugging

To debug the app, you can install node-inspector:

sudo npm install -g node-inspector

Then, launch the Sails app in debug mode:

sails debug

And in another shell, launch node-inspector:

node-inspector --debug-port 5858

You can then visit http://127.0.0.1:8080/debug?port=5858 to see the debugger for the Sails app (which is still accessed via port 1337, as normal).

Branching

Create branches to work on things. When you're done working on it, you can submit a pull request to merge it back into the master branch.

Reference

Some useful links: