Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated anchor links and heading formatting

...

Alloy provides a command-line interface to create a new projects, generate skeleton components, and compile Alloy code to Titanium code. See Command-Line Interface Installation for  for directions on installing the latest released Alloy CLI.

Run appc alloy --help to see all available target options or see the Alloy Command-Line Interface Reference.

Creating a

...

new application

To create an Alloy application, run the following command from your work space directory:

...

A new Alloy project has a folder named app that contains the skeleton Alloy application.

Creating a

...

new application using a test application

Multiexcerpt
MultiExcerptNametestapp

Starting with Appcelerator CLI 5.0.0 or Alloy 1.7.6, you can generate a new Alloy project using a test application from the Alloy Github repo.  (The source code is copied from the global or local install of the Alloy npm package.)

To create an Alloy application based on a test application, first create a skeleton Titanium project, then run the Alloy new command with the --testapp <path_to_test_app> option.  Pass the option the relative path to the test application after the alloy/test/apps path.

Code Block
languagebash
appc new -t titanium --classic -i com.appc.picker -n AlloyPicker
cd AlloyPicker
appc alloy new --testapp ui/picker

Generating

...

components

The CLI can generate skeleton controllers (with views and styles), models, database migrations and widgets. The following commands can be ran from the root folder of the project or the location of the project may be specified with the -o command-line option.  You can also create platform-specific views or controllers using the --platform option.  You can also create views, styles and controllers for a widget by specifying the --widgetname option with the name of the widget.  

Generating a

...

controller

To generate a controller with a style and view, run the following command:

...

This creates app/controllers/<name>.jsapp/styles/<name>.tss, and app/views/<name>.xml.

Generating a

...

view

To generate a view and style without a controller, run the following command:

...

This creates app/styles/<name>.tss and app/views/<name>.xml.

Generating a

...

style

To generate a style for a view-controller, run the following command:

Code Block
languagebash
appc alloy generate style <name> [--widgetname <widget_name>]

...

To generate style files for all view-controllers, run the following command:

Code Block
languagebash
appc alloy generate style --all

If you add new id or class attributes to the markup file, running either of these commands updates the style file with the new attributes.

Generating a

...

model

To generate a model, run the following command:

...

This creates app/models/<name>.js, and app/migrations/DATETIME_<name>.js if the adapter type is 'sql'.

Generating a

...

migration

To generate a standalone migration for a specific model, run the following command:

...

This creates a timestamp-ordered migration file for the model specified, that is, app/migrations/DATETIME_<name>.js

Generating a

...

widget

To generate a basic widget, run the following command:

...

This creates a default widget in the project's app/widgets path, generating a configuration file, controller, style and view: app/widgets/<name>/widget.jsonapp/widgets/<name>/controllers/widget.jsapp/widgets/<name>/styles/widget.tss, and app/widgets/<name>/views/widget.xml. The widget is automatically added as a dependency in the Alloy project's configuration file config.json.

Generating alloy.jmk

To generate the build customization file alloy.jmk, run the following command:

...

This creates the JavaScript Makefile app/alloy.jmk with a few task hooks in place. Refer to Project Build Customization Configuration File (alloy.jmk) for more details.

Extracting

...

localization strings

The alloy extract-i18n command inspects your JS and TSS (since Alloy 1.2.0), and XML files (since Alloy 1.6.0) for instances of Titanium's localization functions and adds those strings to an i18n strings.xml file.  The command has the following syntax:

...

Code Block
languagehtml/xml
[INFO] ######## BEFORE ########
<resources>
  <string name="name">name</string>
  <string name="color">color</string>
  <string name="currency">currency</string>
</resources>
[INFO] ######## AFTER  ########
<resources>
  <string name="name">name</string>
  <string name="color">color</string>
  <string name="currency">currency</string>
  <string name="test">test</string>
</resources>

Compiling a

...

specific view-

...

controller

Starting with Appcelerator CLI 5.0.0 or Alloy 1.7.6, you can select which Alloy view-controller to compile to Titanium code.  Use the command to update the Titanium base code for incremental changes to the Alloy project.  Pass the file=<filename> to the --config option when running the Alloy compile command.

Code Block
languagebash
appc alloy compile --config platform=<platform>,file=<file>
 
## Example
appc alloy compile --config platform=android,file=app/controller/index.js

Building an

...

application

To build and run an application, execute the following command:

...

See the Titanium Command-Line Interface Reference guide for a complete explanation of the available options.

Installing

...

special project components

Installing the

...

compiler plugin

To install the compiler plugin that hooks the Alloy project to Studio, run the following command:

Code Block
languagebash
langnone
appc alloy install plugin [path_to_project]

...