Getting setup for local development is easy. We use io.js, and nvm for managing multiple node versions locally.
- On Mac OS X, install nvm:
brew install nvm
. Note the setup requires some additions to your shell config. - Install iojs with nvm:
nvm install iojs
(now that you have nvm, you can also install the latest Node version with it:nvm install stable
). - Use a node version with nvm's
use
. We want io.js, so:nvm use iojs
- Tip: you can always check the version you are running with
nvm current
- Tip: If, after installing
nvm
andiojs
, you experience issues with v8flags when running gulp, see here.
Once we have our base environment setup to use io.js, then you can configure the actual app:
- Create your own fork of
https://github.com/okfn/opentrials-prototype
- Clone your fork locally with
https://github.com/{YOUR_USERNAME}/opentrials-prototype.git
- Install the dependencies with
npm install
- Run the server with
npm run develop
, and visit the app athttp://localhost:3000
That's it. Other things you can do:
- Run the test suite with
npm test
- Run the server in production mode with
npm start
- Check your code style with
npm run jscs
(according to the Google style guide)
We welcome contributions. Please keep the style consistent. Refer to Open Knowledge Coding Standards.
In summary, in this codebase we:
- Write all code in Node.js-style Javascript using modules, exports and require, and employ Browserify to build front end distributions of the code
- Use two spaces for indentation
- Use semi-colons, and import modules with the full
var {name} = require('{name}');
syntax- No leading commas in this codebase :)
- Accept pull requests on feature branches (e.g.:
feature/my-feature
), or some similar pattern of branches from thedevelop
branch
Also, notice the following conventions:
- All core business logic goes in packages under
src/components
(e.g: theui
package). - Code must have unit tests or functional tests (See examples in the
tests
directory). - All presentation and glue code for the web interface goes under
src/components/ui
. - A browser-compatible build of the code is generated automatically into
dist
- We separate the browser scripts to two bundles:
vendor.min.js
has our dependenciesapp.min.js
has our code
- Dependencies should be managed in
npm
, and notbower
. Add dependencies to this list to include them invendor.min.js
If you are new to some of the tooling we use - don't worry, it is not difficult! Refer to Node Modules, Mocha, Chai, Browserify, Gulp and BrowserSync for further information. These are all key tools to organizing our code and workflow.