cordova-cli has been tested on Mas OS X and Linux.
## Project Commands
platform [ls | list]
list all platforms the project will build toplatform add <platform> [<platform> ...]
add one (or more) platforms as a build target for the projectplatform [rm | remove] <platform> [<platform> ...]
removes one (or more) platforms as a build target for the projectplugin [ls | list]
list all plugins added to the projectplugin add <path-to-plugin> [<path-to-plugin> ...]
add one (or more) plugins to the projectplugin [rm | remove] <plugin-name> [<plugin-name> ...]
remove one (or more) added pluginsprepare [platform...]
copies files into the specified platforms, or all platforms. it is then ready for building by Eclipse/Xcode/etc.compile [platform...]
compiles and deploys the app to a connected and compatible device. With no parameters, builds for all platforms, otherwise builds for the specified platforms.build [<platform> [<platform> [...]]]
an alias for cordova prepare
followed by cordova compile
emulate [<platform> [<platform> [...]]]
launch emulators and deploy app to them. With no parameters emulates for all platforms added to the project, otherwise emulates for the specified platformsserve <platform> [port]
launch a local web server for that platform's www directory on the given port (default 8000).
Project Directory Structure
A Cordova application built with cordova-cli will have the following directory structure:
myApp/
|--.cordova/
|-- merges/
| |-- android/
| |-- blackberry/
| `-- ios/
|-- platforms/
| |-- android/
| |-- blackberry/
| `-- ios/
|-- plugins/
`-- www/
.cordova/
This directory identifies a tree as a cordova project. Simple configuration information is stored in here (such as BlackBerry environment variables).
Commands other than create
operate against the project directory itself, rather than the current directory - a search up the current directory's parents is made to find the project directory. Thus, any command (other than create
) can be used from any subdirectory whose parent is a cordova project directory (same as git).
merges/
Platform-specific web assets (HTML, CSS and JavaScript files) are contained within appropriate subfolders in this directory. These are deployed during a prepare
to the appropriate native directory. Files placed under merges/
will override matching files in the www/
folder for the relevant platform. A quick example, assuming a project structure of:
merges/
|-- ios/
| `-- app.js
|-- android/
| `-- android.js
www/
`-- app.js
After building the Android and iOS projects, the Android application will contain both app.js
and android.js
. However, the iOS application will only contain an app.js
, and it will override the "common" app.js
located inside the www/
folder above.
platforms/
Platforms added to your application will have the native application project structures laid out within this directory.
plugins/
Any added plugins will be extracted or copied into this directory.
www/
Contains the project's web artifacts, such as .html, .css and .js files. These are your main application assets. The config.xml file within this directory is very important; read on to the next section!
Your Blanket: www/config.xml
This file is what you should be editing to modify your application's metadata. Any time you run any cordova-cli commands, the tool will look at the contents of config.xml
and use all relevant info from this file to define native application information. cordova-cli supports changing your application's data via the following elements inside the config.xml
file:
If you are using cordova-cli as a module within a larger node application, you can also use the standard EventEmitter
methods to attach to the events. The events include before_build
, before_compile
, before_docs
, before_emulate
, before_platform_add
, before_platform_ls
, before_platform_rm
, before_plugin_add
, before_plugin_ls
, before_plugin_rm
and before_prepare
. Additionally, there are after_
flavours of all the above events.
This example shows how to create a project from scratch named KewlApp with iOS and Android platform support, and includes a plugin named Kewlio. The project will live in ~/MyProjects/KewlApp
Thanks to everyone for contributing! For a list of people involved, please see the package.json
file.