Class, that acts as abstract on top of Cordova project. Encapsulates the basic properties, that represents project configuration and methods for managing the project. This class shouldn't be instantiated directly. Instead user is intended to use 'getProjectAt' and 'createProject' class methods.
Kind: global function
Param | Type | Description |
---|---|---|
appName | String |
Optional. Application name, that will be used for '' element in config.xml. If not specified, 'HelloCordova' will be used. |
appId | String |
Optional. Application id, that will be used for 'id' attribute of '' element. If not specified 'io.cordova.hellocordova' will be used. |
- CordovaProject(appName, appId)
- instance
- .addPlatform(platformSpec, saveToProject) ⇒
Promise
- .removePlatform(platformName, saveToProject) ⇒
Promise
- .addPlugin(pluginSpec, options) ⇒
Promise
- .removePlugin(pluginId, saveToProject) ⇒
Promise
- .getInstalledPlatforms() ⇒
Object.<String, PlatformApi>
- .getInstalledPlugins() ⇒
Array.<PluginInfo>
- .build(platform, buildOptions) ⇒
Promise
- .run(platform, runOptions) ⇒
Promise
- .clean(platform, runOptions) ⇒
Promise
- .requirements(platform, requirementsOptions) ⇒
Promise.<Array.<Requirement>>
- .addPlatform(platformSpec, saveToProject) ⇒
- static
- instance
Adds a new platform to project.
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled if platform is installed
successfully, or rejected with CordovaError.
Param | Type | Description |
---|---|---|
platformSpec | String |
A platform spec that should be one of following: * valid platform name: 'android', 'windows', etc. * valid npm identifier, that resolves to valid platform: cordova-android@4.0 * git url, that points to repo with valid platform: http://github.com/apache/cordova-android.git#4.0.0 * path to local repo of valid platform: /my/cordova/repositories/cordova-android |
saveToProject | Boolean |
Flag that indicates, that added platform should be saved into project configuration to be easily restored after. The approach is similar to 'npm install --save' command. |
Removes a platform from project.
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled if platform is removed
successfully, or rejected with CordovaError.
Param | Type | Description |
---|---|---|
platformName | String |
A name of platform that should be removed from project. |
saveToProject | Boolean |
Flag that indicates, that platform also should be removed from project configuration. |
Adds a new plugin into project. Installs it to each platform in project.
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled if plugin is installed
successfully, or rejected with CordovaError.
Param | Type | Description |
---|---|---|
pluginSpec | String |
A plugin spec that should be one of following: * valid plugin id that can be resolved through either cordova plugin registry or npm: 'org.apache.cordova.globalization', 'cordova-plugin-globalization' * valid npm identifier, that resolves to valid plugin: cordova-plugin-globalization@1.0.0 * git url, that points to repo with valid plugin: http://github.com/apache/cordova-plugin-globalization.git#r1.0.0 * path to local repo of valid plugin: /my/cordova/repositories/cordova-plugin-globalization |
options | Object |
An options object. Possible options are: * saveToProject: Boolean. Flag that indicates, that added plugin should be saved into project configuration. * link: Boolean. Flag that specifies that plugin sources will be symlinked to app's directory instead of copying if possible. * searchPath: String. Valid path, that will be used to search for plugin in local filesystem. * variables: Object. An object that represents variables that will be used to install plugin. See more details on plugin variables in documentation: https://cordova.apache.org/docs/en/4.0.0/plugin_ref_spec.md.html |
Removes a plugin from project.
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled if platform is removed
successfully, or rejected with CordovaError.
Param | Type | Description |
---|---|---|
pluginId | String |
An id of plugin that should be removed from project. |
saveToProject | Boolean |
Flag that indicates, that plugin also should be removed from project configuration. |
Enumerates all platforms, installed into project.
Kind: instance method of CordovaProject
Returns: Object.<String, PlatformApi>
- An array of PlatformApi instances.
Enumerates plugins, installed into project.
Kind: instance method of CordovaProject
Returns: Array.<PluginInfo>
- An array of PluginInfo instances.
Builds an application package for specified platform. If platform is specified, this acts as a shortcut for getInstalledPlatforms[platform].build(buildOptions).
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled if packages built
successfully, or rejected with CordovaError.
Param | Type | Description |
---|---|---|
platform | String | Array.<String> |
Optional. If not specified, builds packages for all platforms, installed into project. If specified, could be either an array of platform names, which app packages should be built for, or single platform name. |
buildOptions | Object |
A build options. Possible options are: * release: Boolean. Indicates that packages should be built with release configuration. If not set to true, debug configuration will be used. * architectures: String[]. Specifies chip architectures which app packages should be built for. Note: List of valid architectures is specific for each platforms. Also not all platforms supports this option. |
Builds and runs an application package for specified platform on specified device/emulator. If platform is specified, this acts as a shortcut for getInstalledPlatforms[platform].run(runOptions).
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled if application ran
successfully, or rejected with CordovaError.
Param | Type | Description |
---|---|---|
platform | String | Array.<String> |
Optional. If not specified, builds and runs packages for all platforms, installed into project. If specified, could be one of following: * String[]. An array of platform names, which app packages should be built/run for. * String. Equal to 'CordovaProject.run([platform])'. |
runOptions | Object |
Similar to build options. See build doc for options reference. |
Cleans out the build artifacts for specified platform. If single platform is specified, this acts as a shortcut for getInstalledPlatforms[platform].clean(cleanOptions).
Kind: instance method of CordovaProject
Returns: Promise
- A promise either fulfilled or rejected with CordovaError.
Param | Type | Description |
---|---|---|
platform | String | Array.<String> |
Optional. If not specified, builds and runs packages for all platforms, installed into project. If specified, could be one of following: * String[]. An array of platform names, which app packages should be built/run for. * String. Equal to 'CordovaProject.run([platform])'. |
runOptions | Object |
Similar to build options. See build doc for options reference. |
Performs a requirements check for each platforms installed. Each platform defines its own set of requirements, which should be resolved before platform can be built successfully.
Kind: instance method of CordovaProject
Returns: Promise.<Array.<Requirement>>
- Promise resolved with set of
Requirement objects for each platform.
Param | Type | Description |
---|---|---|
platform | String | Array.<String> |
Optional. If not specified, checks requirements for all platforms, installed into project. If specified, could be one of following: * String[]. An array of platform names, which app requirements should be checked for. * String. Equal to 'CordovaProject.requirements([platform])'. |
requirementsOptions | Object |
[description] |
CordovaProject.getProjectAt(projectDir) ⇒ Promise.<CordovaProject>
Gets a CordovaProject instance for specified directory. Returns a cached value, if exists or instantiates a new CordovaProject.
Kind: static method of CordovaProject
Returns: Promise.<CordovaProject>
- Returns a promise either fulfilled with a
Cordova project instance or rejected with CordovaError.
Param | Type | Description |
---|---|---|
projectDir | String |
Path to cordova project. |
CordovaProject.createProject(targetDir, appName, appId, options) ⇒ Promise.<CordovaProject>
Initializes an empty cordova project at specified directory. Copies
Kind: static method of CordovaProject
Returns: Promise.<CordovaProject>
- Returns a promise either fulfilled with a
Cordova project instance or rejected with CordovaError.
Param | Type | Description |
---|---|---|
targetDir | String |
Path to directory, where new project will be created. |
appName | String |
Optional. Application name, that will be used for '' element in config.xml. If not specified, 'HelloCordova' will be used. |
appId | String |
Optional. Application id, that will be used for 'id' attribute of '' element. If not specified 'io.cordova.hellocordova' will be used. |
options | Object |
An options object. See list of common options below: |
options.wwwSource | String |
Specifies the www assets source for new application instead of default one. If not specified, the Cordova HelloWorld assets will be used. |
options.link | Boolean |
Specifies that www source will be symlinked to app's directory instead of copying. |