Skip to content
yuchi edited this page Dec 30, 2014 · 6 revisions

This is a guide to get you up and running as fast as possible, but if your project is something you care about then we suggest you to read [[how to use titaniumifier with Grunt|Getting Started (with Grunt)]].

Requirements

You need to have Node.js and npm installed to follow this mini-guide, but you already have if you have the Titanium SDK environment set up.

To have access to the CLI execute the following in your terminal:

$ [sudo] npm install --global titaniumifier

Quickstart

Create your project directory:

$ mkdir my-awesome-thing
$ cd my-awesome-thing

Initialize a package.json

$ npm init

…and by following the wizard you’ll end up with something like this:

$ cat ./package.json
{
  "name": "my-awesome-thing",
  "version": "1.0.0",
  "description": "Does awesome things!",
  "main": "./index.js"
}

Create an index.js (this is the entry point of your package/module):

// index.js

module.exports.shout = function (s) {
 return s + '!!';
};

And finally launch titaniumifier:

# --in is the directory where *package.json* is (defaults to `.`)
# --out is where you want your zipfile written to (defaults to `.`)
$ titaniumifier --in . --out .

But we get an error!

 ℹ  working on '/path/to/my-awesome-thing'
 ℹ  will write in '/path/to/my-awesome-thing'

 ✖  errors!

Fatal error: No `guid` found. Here’s one for you: 946f6eea-6afd-0508-0854-518c1150dc3b

Modify the package.json file to include the missing guid (the error has built a random one for you):

{
  "name": "my-awesome-thing",
  "version": "1.0.0",
  "description": "Does awesome things!",
  "titaniumManifest": {
    "guid": "946f6eea-6afd-0508-0854-518c1150dc3b"
  },
  "main": "./index.js"
}

Run titaniumifier again:

$ titaniumifier --in . --out .

 ℹ  working on '/path/to/my-awesome-thing'
 ℹ  will write in '/path/to/my-awesome-thing'

 ✔  zip correctly built

🎉 Awesome! You now have a titaniumified package as my-awesome-thing-commonjs-1.0.0.zip in your project root directory!

What’s next?

If reached this point you probably want to read about the anatomy of a project or how to setup automated testing.

Even better! You can setup Grunt to automate your build process!

If you want, you can also have a look at some examples of titaniumifier in the wild.

Clone this wiki locally