A command line build tool

I built capt to help me build single page apps. Tools like Jammit are great for when you’re working in a rails environment, but I found there weren’t any really good tools for building apps that are standalone, for example couchapps, or standalone javascript apps that use XMPP or access a javascript api.

Imagine you’re building the new twitter interface, capt is designed to build something like that.

Alpha release!

Capt has been under development since November ‘10, but it’s still very alpha, expect things to be missing / broken.


There is a tutorial here, it’s incomplete, feel free to clone the documentation branch and send me push requests.


Installation requires npm, then:

npm install capt

Some code generation

Try this out to get an idea of what you can do.

sudo npm install capt
capt new project
cd project
capt generate model post
capt generate controller posts
capt server
open http://localhost:3000/spec/
open http://localhost:3000/

You should get 7 passing tests and some stubs to work with.

Ignoring .js and .css directories

Add .js/ and .css/ to your .git/info/exclude file. This will ignore all the hidden .js and .css files that are generated by capt.

Create app structure

Run capt new project to create a project directory. Capt will creates the necessary files to get you up and running and will download the latest jQuery / backbone.

Compiles .jst templates

You specify what your static html is going to look like as a .jst file, and capt will compile your index.html. You can include the following lines:

<%= project.stylesheetIncludes() %>
<%= project.scriptIncludes() %>

This will include seperate javascript files (in the correct dependency order) in development mode, or compile them all to one minimized file in production mode.

Serves your app

You can start an node-powered webserver on port 3000 using:

capt server

Serves your jamine specs

By default your app will have a /spec/ directory that includes jasmine and an index.jst. When you generate new models, capt will generate a stub spec in /spec/models/. Run the specs by browsing to http://localhost:3000/spec/.

Manages dependency order and autoloads

Specify files in config.yml. The default config.yml looks like this:

  - 'lib/jquery.js'
  - 'lib/underscore.js'
  - 'lib/backbone.js'
  - 'lib/less.js'
  - 'app/controllers/*.coffee'
  - 'app/views/**/*.coffee'
  - 'app/models/*.coffee'

  - 'public/stylesheets/*.less'

  - 'spec/*/*.coffee'

Add files to each section to specify build order. Files will only be included once. For example:

  - 'app/models/'
  - 'app/models/*.coffee'