Do I need Lineman?
If you're starting a new project that will be deployed as static web assets, Lineman might be a great fit for you.
Some things it helps with:
- Immediately compile CoffeeScript, Less, and client-side templates as you edit source files
- Provide a development server for fast feedback
- Run specs on demand with
lineman specusing Testem
- Run specs with output suitable for your CI server using
Just think of it as a handful of conventions and tasks that can help you get up-and-running more quickly than deciding on path names and configuring all the requisite grunt tasks yourself.
Next, you'll need to install Grunt & Lineman globally:
$ npm install -g grunt lineman
To create a new project, run the
lineman binary with the
new command and tell it where you'd like the project to go:
$ lineman new my-project
This will create a new directory named "my-project" and copy in Lineman's archetypal project.
Your new project will, by default, have Lineman and grunt-contrib as development dependencies.
Finally, you'll probably want to crack open your project' package.json file. That is, of course, unless you plan to give John Doe all the credit.
Working with Lineman
To see all of the options available to you in the terminal use the
$ lineman --help
From the project directory, you can start a server at localhost:8000:
$ lineman run
watch task will monitor for file changes and Lineman will make sure that any requisite compilation & concatenation occur, based on the type and location of the file change.
With any luck, visiting the server in your browser will yield something as beautiful as this:
The Hello World code shows off JST compilation, CoffeeScript, and Less. When you edit a source file, your changes are usually reflected by the time you can refresh your browser.
Lineman provides a way to run your specs constantly as you work on your code with the
lineman spec command:
$ lineman spec
lineman spec requires
lineman run to be running in a different process to monitor file changes..
spec command will launch the fantastic test framework Testem supports Safari, Chrome, Firefox, Opera, PhantomJS and (IE9, IE8, IE7 if on Windows). By default we have configured Testem to launch Chrome for tests during development.
You can override this by modifying the
launch_in_dev property within
We have found that running tests in Chrome during development is ideal as it enables the insertion of
Continuous Integration Specs
You can also run specs with output generated for your CI environment in TAP 13 format:
$ lineman spec-ci
This configuration executes specs headlessly using only PhantomJS. You can override this by modifying the
launch_in_ci property within
When you're ready to send your application off to a remote server, just run the
lineman build task.
$ lineman build
The above runs a task that produces a production-ready web application in the project's
To clean the two build directories (
generated), just run the clean task:
$ lineman clean
Project directory structure
Lineman generates a very particular directory structure. It looks like this:
Lineman got its name from finding that the word "grunt" was first used to describe unskilled railroad workers. Grunts that made the cut were promoted to linemen.
All we wanted was a cozy & productive application development tool that didn't saddle our client-side code with a particular server-side technology. Intentionally dividing backend and front-end projects applies a healthy pressure to decouple the two.
It doesn't hurt that with Lineman, we're able to bootstrap new client-side apps faster than we ever have before.