A grunt-based project archetype tool for fat-client HTML/JS/CSS apps.
Pull request Compare This branch is 615 commits behind linemanjs:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
archetype
config
lib
tasks
.gitignore
README.md
cli.js
lineman.js
package.json

README.md

Lineman

Lineman is a tool for bootstrapping fat-client webapp projects. It requires node.js & npm and wouldn't be possible without grunt.

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
  • Concatenate & minify all your CSS & JavaScript for production

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.

Getting started

First, you'll need PhantomJS to run tests. Here's are some instructions.

Next, you'll need to install Grunt & Lineman globally:

$ npm install -g grunt lineman

To create a new project, run the lineman binary where you'd like the project to go:

$ lineman my-new-project

This will create a new directory named "my-new-project" and copy in Lineman's archetypal project.

Your new project will, by default, have Lineman and grunt-contrib as development dependencies. To install them:

$ cd my-new-project; npm install

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

Development

From the project directory, you can start a server at localhost:8000:

$ grunt run

Grunt's 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:

Development Screenshot

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.

Additionally, while grunt run is running, testacular will be monitoring any changes to the application, and will re-execute the specs as needed.

Production

When you're ready to send your application off to a remote server, just run the default grunt task.

$ grunt

The above runs a default task that produces a deployable web application in the project's dist/ directory, ready to be deployed to production.

Cleaning

To clean the two build directories (dist and generated), just run the clean task:

$ grunt clean

Project directory structure

Lineman generates a very particular directory structure. It looks like this:

.
├── app
│   ├── js                  # <-- JS & CoffeeScript
│   ├── img                 # <-- images (are merged into the root of generated & dist)
│   └── templates           # <-- client-side templates
│       ├── homepage.us     # <-- a template used to produce the application's index.html
│       ├── other.us        # <-- other templates will be compiled to a window.JST object
│       └── thing.handlebar # <-- underscore & handlebars are both already set up
├── config
│   ├── application.js      # <-- Override application configuration
│   └── files.js            # <-- Override named file patterns
├── dist                    # <-- Generated, production-ready app assets
├── generated               # <-- Generated, pre-production app assets
├── grunt.js                # <-- gruntfile defines app's task config
├── package.json            # <-- Project's package.json
├── tasks                   # <-- Custom grunt tasks can be defined here
├── spec
│   ├── helpers             # <-- Spec helpers (loaded before other specs)
│   └── some-spec.coffee    # <-- All the Jasmine specs you can write (JS or Coffee)
└── vendor                  # <-- 3rd-party assets will be prepended or merged into the application
    ├── js                  # <-- 3rd-party Javascript
    │   └── underscore.js   # <-- Underscore, because underscore is fantastic.
    ├── img                 # <-- 3rd-party images (are merged into the root of generated & dist)
    └── css                 # <-- 3rd-party CSS

About

the name

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.

the motivation

Most fat-client web applications are still written as second-class denizens within server-side project directories. This has inhibited the formation of a coherent community of people who write applications HTML, CSS, and JavaScript, because the server-side technology is dominant. Front-end work on a Rails project differs greatly from front-end work on a Java project, even though they're building the same thing!

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.

the terms

Lineman was created by test double, a software studio in Columbus, Ohio. It's distributed under the MIT license.