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.
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 sassThe -g flag installs the packages globally, so you can easily access them.
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 restartYou should then be able to enter a psql console by running psql --username=postgres.
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:createor
createdb -U postgres ittybitty_devTo drop the database, you could do it manually in psql or run:
sails-migrations db:dropWe are using sails-migrations for database migrations and sails-postgresql as the adapter.
Start a local server by running:
sails liftYou can then view the web app in your browser at http://localhost:1337/ (or http://0.0.0.0:1337/).
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 appYou 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.
To debug the app, you can install node-inspector:
sudo npm install -g node-inspectorThen, launch the Sails app in debug mode:
sails debugAnd in another shell, launch node-inspector:
node-inspector --debug-port 5858You 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).
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.
Some useful links:
- Sails documentation (a lot of the links in the included comments in the app are out of date)
- Waterline docs for writing queries
- An example Sails tutorial
- A handy REST client for Chrome