Hybrid rendering app for the GOV.UK Performance Platform using Backbone and D3. JavaScript is shared between the client and server, and the app makes use of progressive enhancement to provide a great experience in every browser.
Just Spotlight: The simplest way to get started is to run just this app, against production data. You can run the app as follows:
npm install -g grunt-cli # install grunt globally
npm install
grunt
Now you should be able to connect to the app at http://localhost:3057
.
The app uses node-supervisor and grunt-contrib-watch to monitor changes, automatically restart the server and recompile Sass.
By default, this will look at production data, but perhaps you want to connect
to a different data source. You can do that
by creating your own config file in /config/config.development_personal.json
that mimics
/config/config.development.json
with a different backdropUrl
property. It'll be ignored by Git.
Full stack: if you're using our development environment then you can run all our apps in one go and use a real database for development. As a bonus, this will let you test the image fallbacks using the screenshot-as-a-service app.
First, you need to set up the Performance Platform development environment.
Once you've got a machine that has the required system-level dependencies, you can install application dependencies with:
npm install
And finally run the application:
cd /var/apps/pp-development
bundle install # install bowler
bowl performance
Tests are divided into ones that work on both client and server (test/spec/shared
), ones that are server-only (test/spec/server
) and ones that are client-only (test/spec/client
).
grunt test:all
runs all three of these tests, as well as linting the codebase:
grunt jasmine_node
executes shared and server Jasmine tests in Node.jsgrunt jasmine
executes shared and client Jasmine tests in PhantomJSgrunt shell:cheapseats
executes feature tests using cheapseats
When the app is running in development mode, Jasmine tests for shared
components are available at /tests
. The specrunner gets automatically
recreated on server start and when the specfiles change. Due to a
bug in grunt-contrib-watch, new spec files are not currently
detected automatically. When you add a new spec file, either restart the
app or run grunt jasmine:spotlight:build
.
Install node-inspector where the app runs with sudo npm install -g [email protected]
and run it with node-inspector
.
Start the app with node --debug app/server.js
and visit http://spotlight.perfplat.dev:8080/debug
to view the console.
grunt build:production
to create a production release.
NODE_ENV=production node app/server.js
to run the app in production mode.
If you want to deploy the app to Heroku, follow these instructions.
The app runs on Heroku using a custom buildpack for Grunt.js support:
heroku create spotlight-demo-feature --buildpack https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt.git
heroku config:set NODE_ENV=development npm_config_production=false
git push heroku your-branch-name:master
heroku open
If you want the Heroku app to be password-protected, set config variables as follows, before pushing the code.
heroku config:set BASIC_AUTH_USER=xxxx
heroku config:set BASIC_AUTH_PASS=xxxx
heroku config