PhoneGap Build CLI
PhoneGap Build command-line interface and node.js library.
Getting Started on the Command-line (CLI)
CLI: Install
$ sudo npm install -g phonegap-build
CLI: Usage
Usage: phonegap-build [options] [commands]
Synopsis:
PhoneGap Build command-line environment.
Commands:
login login to phonegap build
logout logout of phonegap build
create <path> create a phonegap project
build <platform> build a specific platform
help [commands] output usage information
Options:
-v, --version output version number
-h, --help output usage information
Getting Started with Node.js
Node.js: Install
package.json
:
{
"dependencies": {
"phonegap-build-cli": "*"
}
}
Require
var build = require('phonegap-build-cli');
Login
Authenticates with PhoneGap Build, saves the token, and return an API object.
When the save token exists, the authentication step is skipped.
Options:
options
{Object} contains the login credentials.options.username
{String} is the username.options.password
{String} is the password.- [
callback
] {Function} is called after the login.
e
{Error} is null on a successful login attempt.api
{Object} the API object defined by phonegap-build-rest
Events:
error
is triggered on an error.
e
{Error} details the error.
complete
is trigger when there is no error.
api
{API} is instance of phonegap-build-api object.
Example:
build.login({ username: 'zelda', password: 'tr1force' }, function(e, api) {
// pass `api` to other phonegap build commands
});
Logout
Logout the user by deleting the token key from the config file.
Options:
args
{Object} is unused and should be {}
.- [
callback
] {Function} is a callback function.
e
{Error} is null unless there is an error.
Events:
error
is trigger on an error.
e
{Error} details the error.
complete
is trigger when there is no error.
Example:
build.logout({}, function(e) {
console.log('now logged out.');
});
Create a New App
Creates an application on the local filesystem and also remotely on
PhoneGap Build. The remote application is linked by storing the app ID
inside the application's config file.
Options:
options
{Object} is data required to create an app
api
{Object} is a phonegap-build-rest API object.path
{String} is a directory path for the app.name
{String} is the app name give to PhoneGap Build.
- [
callback
] {Function} is triggered after creating the app.
e
{Error} is null unless there is an error.
Events:
error
is trigger on an error.
e
{Error} details the error.
complete
is trigger when no error occurs.
Example:
build.create({ api: api, path: 'path/to/new/app', name: 'My App' }, function(e) {
});
Build an App
The build task will compress the application, upload it to PhoneGap Build,
and poll until the platform's build status is complete or an error is
encountered.
Options:
options
{Object} is data required for building a platform.options.api
{Object} is the phonegap-build-api API object.options.platforms
{Array} is a collection of platform names {String} that
specify the platforms to build.- [
callback
] {Function} is triggered after the build is complete.
e
{Error} is null unless there is an error.
Events:
error
is trigger on an error.
e
{Error} details the error.
complete
is trigger when no error occurs.
Example:
build.build({ api: api, platforms: ['android'] }, function(e) {
});