The rise of the framework
It starts with Node
Lineman is a Node.js-based project build tool with a focus on assisting with all of the previously mentioned tasks. You must install Node.js fore diving into Lineman. The Node Package Manager is used to install the tool, as the following command line illustrates.
> sudo npm install âg lineman
On the Lineman site, I read that installing PhantomJS to facilitate testing is recommended. Using Lineman involves a few simple commands. The following command creates a new Lineman-based application using Lineman’s default, framework-agnostic project template.
> lineman new LinemanExample
Figure A shows the creation of the new Lineman web application. Once the application is created, navigate to its new directory (LinemanExample in this case) and use the run command to start the web server (it uses Express JS) as shown in Figure B.
> lineman run
Creating a new application with Lineman.
Starting the Lineman web server.
Once the web server is running, you can open the application in your browser — the default port used for the local web server is 8000 so navigate to http://localhost:8000 to load the application. The example is opened in Figure C. This opens the default page (index.html), which is defined in the index.us file located in the app\pages directory. Additional templates are stored in the app\templates directory.
Viewing the newly created Lineman site in Chrome.
> git clone https://github.com/linemanjs/lineman-angular-template.git AngularTest
A Lineman application’s directory contains numerous files and directories, including these five:
- app: This directory contains application files and assets. It includes js, img, static, pages, and templates.
- dist: This directory is populated with generated content/files when the build command is executed.
- package.json: This is the application’s package.json file.
- spec: Testing is configured in the config/spec.json file, but specific testing tools/helpers are set up in the spec directory, specifically in the helpers directory.
Running Lineman application with spec option.
The Lineman application loaded in test mode.
An additional command that deserves mention is fetch; it allows you to download well-known libraries and install them in your Lineman application. As an example, I installed jQuery with the following command issued in the Lineman application directory where it will be used.
> lineman fetch jquery
Focus on development
After the initial learning curve, Lineman delivers on its promise. It is much easier to get up and running and actually use its basic features than another option like Yeoman, but that may be just my bias since I have been working with Node.js a lot. Rackspace uses Lineman for its environment, so it must do something well.
I’ve only scratched the surface of what Lineman can do, so please take a closer look at the online documentation to take full advantage of the tool. If you’re already using Lineman, what do you like or not like about it? Let us know in the discussion.