atesh/XKit — pull request #167 by OnAzureWings (2014-10-13 18:07:40+00:00)
Title: Implement proper build scripts

This pull request implements more fully-featured build scripts than what we currently have with [`build.sh`](https://github.com/atesh/XKit/blob/66481a662dfe94c8af9f50c6fcc21990f7e367ed/build.sh).

---

Dependencies

The build scripts are built on top of [Grunt](http://gruntjs.com/), which requires [Node.js](http://nodejs.org/) (and [npm](https://www.npmjs.org/), but npm comes bundled with Node.js) installed on the system.

Setup

Once Node.js is installed, simply `cd /path/to/XKit/` and run `npm install` to install all of the required dependencies.

Running Tasks

There are a number of tasks that can be run:

Code Linting

Code linting is implemented with [JSHint](http://www.jshint.com/docs/).

Run linting with either `npm test` or `grunt jshint`. The default grunt command `grunt` is also set to run code linting as the default task.

Building Browser Extensions

To build the browser extensions as done with `build.sh`, run `grunt build`. Builds are written to `build/releases`.

By default, `grunt build` will build all of the browser extensions. To specify a subset of browser extensions to build, simply use Grunt's multi-task syntax to specify a comma-separated list of known build targets.

Usage: `grunt build[:` is one or more of `chrome,firefox,safari`

Ex:
```sh
grunt build:chrome,safari
```
will build the browser extensions for Chrome and Safari (and not Firefox).

Auto Code Linting

Grunt can poll the filesystem for changes to watched files and run the linting tasks when watched files are changed. You don't have to continuously retype `grunt jshint` every time you make a change and want to lint.

Usage: `grunt watch[:]` were `` is one or more of `gruntfile,extensions,chrome,firefox,safari`.

Ex:
```sh
grunt watch:extensions
```
will watch the `Extensions/` directory for changes and run the linting tasks when an extension file is edited, and will not lint any other files in the project.

---

Feedback would be appreciated, especially around the strictness of the code linting. I did my best to set what I thought were reasonable defaults, and I've suppressed a number of errors that I don't believe apply to the project (see the [.jshintrc file](https://github.com/OnAzureWings/XKit/blob/332799f7fe674453a07b0a4f3780862838b2760a/.jshintrc#L10-12) and [lint-explain](http://lint-explain.herokuapp.com/) to understand the error codes).

Even with these suppressions, the codebase is still very much __not__ lint-free, and there's a fair amount of work to do in terms of cleaning things up, especially with regards to the extensions.

Cheers.