Understanding the Unified Appcelerator CLI

With the launch of the Appcelerator Platform 4.0 we introduced the Unified Appcelerator CLI. This new appc[elerator] CLI replaced the ti[titanium], alloy and acs CLIs.

But then, it also didn’t.

And that can be confusing, in particular when you are updating after a new release. So, let’s find out how the Unified CLI works.

The Big Picture

Let’s start with an image that might very well say enough and if it doesn’t, will help us as we go through the different components of the Unified CLI.


The Installer

The global appcelerator NPM package that you install via [sudo] npm i -g appcelerator or Studio is pretty much an empty shell as you can see on its repo. All it needs to do is handle installing and switching between different core packages. Very similar (but not entirely identical) to what Grunt does.

We’ve done this to make it easier to switch between versions that work together on specific versions of the Titanium SDKs and deployments of Arrow Cloud.

Use appc use to list all available versions and appc use <version> to install or switch to one.

NOTE: Be aware that appc -v will get you the version of the active core package, not the installer. To get the version of the installer as well, run appc info or appc -v -o json.

The Core Package

The core package has a plugin architecture. When you use appc run, either the Arrow or Titanium plugin will volunteer to handle the request, depending on the type of project you’re in. When you run appc new then both plugins will offer options to select from.

The Titanium plugin depends on the original Titanium and Alloy CLI, as does Arrow on the ACS CLI. These are local dependencies, so there’s no need to install the original CLIs to build a Titanium or Arrow app via the Unified CLI.

NOTE: Be aware that the global Titanium CLI does share its configuration (in ~/.titanium) with the one embedded in the active core.

Switching Node.js versions

Some of our core package dependencies use Node.js addons that extend the Node.js interface between JavaScript and C/C++ libraries. These need to be compiled for your OS and Node.js version, which is done when you install an NPM package.

If you install or switch between Node.js versions that have different APIs, these addons will need to be rebuild. Since 4.2.2 of the Appcelerator Installer we try to detect and do this for you automatically. If you somehow still run into [Error: Module did not self-register.] and similar messages, you can force a reinstall of a core package by adding the --force flag:

appc use 5.2.0 --force

Access to the embedded Titanium, Alloy and ACS CLIs

You can still access the original CLIs as they are embedded in the active core package. Simply prefix the command with appc <cli> <command>. For example:

appc alloy generate controller my-controller

This also allows you to get the versions of the embedded CLIs:

  • appc ti -v (also included in appc info)
  • appc alloy -v
  • appc acs -v

NOTE: We prefer to use appc cloud, which is simply an alias of acs.