Cordova - Plugman


Advertisements

Cordova Plugman is a useful command line tool for installing and managing plugins. You should use plugman if your app needs to run on one specific platform. If you want to create a cross-platform app you should use cordova-cli which will modify plugins for different platforms.

Step 1 - Installing Plugman

Open the command prompt window and run the following code snippet to install plugman.

C:\Users\username\Desktop\CordovaProject>npm install -g plugman

Step 2 - Installing Plugins

To understand how to install the Cordova plugin using plugman, we will use the Camera plugin as an example.

C:\Users\username\Desktop\CordovaProject>plugman  
   install --platform android --project platforms\android  
   --plugin cordova-plugin-camera 
   plugman uninstall --platform android --project platforms\android  
   --plugin cordova-plugin-camera 

We need to consider three parameters as shown above.

  • --platform − platform that we are using (android, ios, amazon-fireos, wp8, blackberry10).

  • --project − path where the project is built. In our case, it is platforms\android directory.

  • --plugin − the plugin that we want to install.

If you set valid parameters, the command prompt window should display the following output.

Plugman Install CMD Output

Additional Methods

You can use the uninstall method in similar way.

C:\Users\username\Desktop\CordovaProject>plugman uninstall  
   --platform android --project platforms\android --plugin cordova-plugin-camera 

The command prompt console will display the following output.

Plugman Uninstall CMD Output

Plugman offers some additional methods that can be used. The methods are listed in the following table.

S.No Method & Details
1

install

Used for installing Cordova plugins.

2

uninstall

Used for uninstalling Cordova plugins.

3

fetch

Used for copying Cordova plugin to specific location.

4

prepare

Used for updating configuration file to help JS module support.

5

adduser

Used for adding user account to the registry.

6

publish

Used for publishing plugin to the registry.

7

unpublish

Used for unpublishing plugin from the registry.

8

search

Used for searching the plugins in the registry.

9

config

Used for registry settings configuration.

10

create

Used for creating custom plugin.

11

platform

Used for adding or removing platform from the custom created plugin.

Additional Commands

If you are stuck, you can always use the plugman -help command. The version can be checked by using plugman -v. To search for the plugin, you can use plugman search and finally you can change the plugin registry by using the plugman config set registry command.

NOTE

Since Cordova is used for cross platform development, in our subsequent chapters we will use Cordova CLI instead of Plugman for installing plugins.

Advertisements