How to develop apps for Firefox OS
| Tags: front-end
I've been lucky enough to be in contact with Firefox OS at work in the past months. And one thing that we did there is a Yeoman generator for Firefox OS.
Yeoman is a tool that creates app scaffolds. It comes with a few templates (aka generators), but we can add our own —such as this one. When we run Yeoman, we will be asked several questions to customise the scaffolding, such as the app name, or whether we want to use an MVC framework or not.
Besides the directory structure, we get something more valuable: a Gruntfile
. Grunt is used to automate tasks (think of it as Node's Rake or Fabric). The Gruntfile
that you'll get with the Firefox OS generator has some useful tasks already configured:
- Install the app into an actual Firefox OS device (without having to download Gaia).
- Run tests.
- Launch a local server (so you can try the app in a browser).
- Compile Sass stylesheets.
- Build a zip file to upload to the Marketplace.
- Run a JavaScript linter to analyse your code.
- Etc.
To use this, you just need to install Grunt, Yeoman and the generator:
npm install -g grunt-cli
npm install -g yo
npm install -g generator-firefoxos
Once you've done that, you can launch the generator with:
yo firefoxos
And here's a short screencast that will guide you through the first steps: deploy the app, write some tests, use Gaia's Building Blocks, etc.