Version 0.4 Last updated: Monday 6 December 2016
This is a guide to get your environment set up to contribute to the digital pattern library.
The digital pattern library code is stored in a Git repository, so you will need a Git client to clone it to your local machine and commit changes back to the repository.
If you are a Windows user, we recommend that you always install the Git command line client, as this will allow you to right-click within a folder and select "Git Bash Here" to open a command-line prompt. You can use this to run Git, Node, Grunt, and Ruby commands.
There are also a number of GUI clients available; our favourites, in order, are:
The digital pattern library uses Grunt, the JavaScript task runner, to automate the build process. Grunt is built on Node.js which is a JavaScript runtime that uses Google Chrome's V8 JavaScript engine. If you're not familiar with either of these see Getting started with Grunt for the basics.
To install Node.js:
- Visit http://nodejs.org/
- Download the latest stable release.
- Run the installer.
Next install the Grunt command line interface (CLI). Open a "Node.js command prompt" (Windows), Terminal (OS X), or shell (*nix) and run the following command:
$ npm install -g grunt-cli
We also use Compass to compile Sass code to CSS. This requires Ruby.
The easiest way to install Ruby is with RubyInstaller for Windows.
When prompted at the beginning of the installation make sure to check the box with the label "Add Ruby executables to your PATH". This will mean that you can run commands like gem install ...
.
Once you're finished with the installation, you should close and reopen any command prompts that you have since they will need to get the updated PATH with Ruby added.
Recent versions of MacOS X already have Ruby installed, no further installation is required.
Clone the Git repository into a folder on your computer using your Git client, or at the command line:
git clone https://github.com/standrewsdigital/digital-pattern-library.git
-
At the command line, navigate to the folder containing your local clone of the pattern library.
$ cd path/to/folder
Where
path/to/folder
is the path to the folder you cloned the pattern library locally. (Or in Windows right-click within the folder containing your local clone of the pattern library and select 'Git Bash'.) -
Install the dependencies for building the pattern library using the Node package manager, npm. The
package.json
file defines what dependencies are installed.$ npm install
If you get an error such as
npm ERR! Error: Command failed: fatal: unable to connect to github.com:
it may be that you are behind a firewall and need to use https instead of git and git+ssh. Append the following to your .gitconfig
file:
# Use https instead of git and git+ssh
[url "https://github.com/"]
insteadOf = git://github.com/
[url "https://github.com/"]
insteadOf = git@github.com:
You can always find the location of your .gitconfig
file by typing the following command into a command prompt: git config --global --edit
.
(On Windows, to exit this editor press Ctrl+C
, then type :quit
and press Enter.)
Install the Compass Ruby gem to compile Sass code into CSS.
$ gem install compass
You should now be configured to start work on the pattern library. You should now read CONTRIBUTING.md for some guidelines and principles of development.
If you already have the DPL installed and need to update the underlying packages start here:
To find out which version you have, run node -v
using Git Bash or the command line.
Update to version 6.9.1 LTS
if you don't already have it from http://nodejs.org/. All the default installation options work so there is no need to change them.
Use your prefered Git client to checkout the branch containing the updated package.json
files.
This can be found within the root of the DPL folder. This may take a long time due to the size of these files.
Run npm install
using Git Bash or the command line.
Run grunt
and if it works then you're successfully updated.
If you get the following error when running Grunt:
Running "assemble:core_meta" (assemble) task
handlebars does not support render.
Assembling core/build.json ERROR
Warning: handlebars does not support render. Use --force to continue.
Aborted due to warnings.
it may be that npm install
did not complete. It has been reported on Stack Overflow that sometimes node doesn't recursively install the modules for assemble-handlebars; this is a known issue in grunt-assemble, issue #31.
You can easily test for this by adding a pre-release identifier to the version number in package.json
, e.g.
"version": "0.9.0-alpha",
If grunt
breaks after adding this, do the following:
- At the command line (e.g. using Git Bash) navigate to
node_modules/assemble-handlebars
. - Run
npm install
. - The remaining modules will install.
- Run
grunt
– it should complete successfully now.