$ npm install -g plugman
你必须在你的 PATH 上有 git,才能直接从远程 git url 安装插件。
$ plugman install --platform <ios|android> --project <directory> --plugin <name|url|path> [--plugins_dir <directory>] [--www <directory>] [--variable <name>=<value> [--variable <name>=<value> ...]]
$ plugman install
--platform <ios|android>
--project <directory> 项目所在目录
--plugin <name|url|path> 此存储库的内容将复制到--plugins_dir
[--plugins_dir <directory>] 默认为<project>/cordova/plugins
[--www <directory>] 默认为项目的www
, used as cordova project application web assets.
[--variable <name>=<value> [--variable <name>=<value> ...]]
Parameters:
例如安装核心插件的示例:
plugman install --platform <ios|android> --project <directory> --plugin cordova-plugin-battery-status
plugman install --platform <ios|android> --project <directory> --plugin cordova-plugin-camera
$ plugman uninstall --platform <ios|android> --project <directory> --plugin <id> [--www <directory>] [--plugins_dir <directory>]
$ plugman uninstall --platform <ios|android> --project <directory> --plugin <id> [--www <directory>] [--plugins_dir <directory>]
$ plugman create --name <pluginName> --plugin_id <pluginID> --plugin_version <version> [--path <directory>] [--variable NAME=VALUE]
Parameters:
例如我$ plugman create --name MyPluginName --plugin_id cordova-plugin-my --plugin_version 0.0.1
Javascript 接口提供了面向前端的接口,但是你需要调用 cordova.exec 与本地平台通信,使用以下语法:
示例一: 官网示例
window.echo = function(str, callback) {
cordova.exec(callback, function(err) {
callback('Nothing to echo.');
}, "Echo", "echo", [str]);
};
示例二: 自定义plugin生成
var exec = require('cordova/exec');
exports.coolMethod = function (arg0, success, error) {
exec(success, error, 'MyPluginName', 'coolMethod', [arg0]);
};
示例三: device.js
cordova.define("cordova-plugin-device.device", function(require, exports, module) {
var exec = require('cordova/exec');
...
module.exports = new Device();
$ plugman platform add --platform_name <platform>
Parameters:
必须在 cd platform directory 该级目录后操作
Creates a package.json file in the plugin based on values from plugin.xml.
$ plugman createpackagejson <directory>
想这样
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
cordova plugin add C:\Users\HD\GaoDeLocation
$ plugman -help
plugman manages plugin.xml-compatible cordova plugins into cordova-generated projects.
To display this help file, use one of the following:
$ plugman --help
$ plugman -h
To display the plugman version, use one of the following:
$ plugman --version
$ plugman -v
--debug|-d : Verbose mode
$ plugman install --platform <platform> --project <directory> --plugin <plugin> [--variable NAME=VALUE]
Parameters:
Optional parameters:
卸载 plugin
$ plugman uninstall --platform <platform> --project <directory> --plugin <plugin-id>
Parameters:
NOTICE: The Cordova Plugin registry became read-only, so the following commands have been deprecated and removed:
$ plugman adduser
$ plugman publish
$ plugman unpublish
$ plugman owner add/rm
For managing plugins for the npm registry, use corresponding npm commands. For more info on npm commands see npm help <command>
.
Learn more about publishing your plugins to npm at http://plugins.cordova.io/npm/developers.html
$ plugman search <keyword1 keyword2 ...>
$ plugman info <pluginID>
Display current configuration settings:
$ plugman config ls
Display the current registry URL:
$ plugman config get registry
Set registry URL:
$ plugman config set registry <url>
Example:
$ plugman config set registry http://localhost:5984/registry/_design/app/_rewrite
Plugin owners are allowed to publish updates to a plugin. To display a list of owners for a plugin, use:
$ plugman owner ls <pluginID>
Example:
$ plugman owner ls org.apache.cordova.core.file
$ plugman create --name <pluginName> --plugin_id <pluginID> --plugin_version <version> [--path <directory>] [--variable NAME=VALUE]
Parameters:
Creates a package.json file in the plugin based on values from plugin.xml.
$ plugman createpackagejson <directory>
$ plugman platform add --platform_name <platform>
Parameters:
$ plugman platform remove --platform_name <platform>
Parameters: