05. 使用 cordova plugman 编辑和添加插件

简介: 05. 使用 cordova plugman 编辑和添加插件

安装 Plugman


$ npm install -g plugman


你必须在你的 PATH 上有 git,才能直接从远程 git url 安装插件。


添加 Plugin


$ 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:


  • platform <platform>: One of android, ios, blackberry10, wp8, or windows8
  • project <directory>: Path reference to a cordova-generated project of the platform you specify


  • plugin <plugin>: One of a path reference to a local copy of a plugin, or a remote https: or git: URL pointing to a cordova plugin (optionally append #branch:subdir) or a plugin ID from http://plugins.cordova.io


  • variable NAME=VALUE: Some plugins require install-time variables to be defined. These could be things like API keys/tokens or other app-specific variables.


Optional parameters:


  • www <directory>: www assets for the plugin will be installed into this directory. Default is to install into the standard www directory for the platform specified


  • plugins_dir <directory>: a copy of the plugin will be stored in this directory. Default is to install into the <project directory>/plugins folder


  • searchpath <directory>: when looking up plugins by ID, look in this directory and each of its subdirectories for the plugin before hitting the registry.
    Multiple search paths can be used by either specifying the flag multiple times, or by separating paths with a delimiter (: on 'nix, ; on Windows).


例如安装核心插件的示例:


  • cordova-plugin-battery-status
    plugman install --platform <ios|android> --project <directory> --plugin cordova-plugin-battery-status


  • cordova-plugin-camera
    plugman install --platform <ios|android> --project <directory> --plugin cordova-plugin-camera


Uninstall a plugin 卸载插件

$ 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>]


  • platform <platform>: One of android, ios, blackberry10, wp8, or windows8
  • project <directory>: Path reference to a cordova-generated project of the platform you specify


  • plugin <plugin-id>: The plugin to remove, identified by its id (see the plugin.xml's <plugin id> attribute)


Create A Plugin 创建插件


$ plugman create --name <pluginName> --plugin_id <pluginID> --plugin_version <version> [--path <directory>] [--variable NAME=VALUE]


Parameters:


  • <pluginName>: The name of the plugin


  • <pluginID>: An ID for the plugin, ex: org.bar.foo


  • <version>: A version for the plugin, ex: 0.0.1


  • <directory>: An absolute or relative path for the directory where the plugin project will be created


  • variable NAME=VALUE: Extra variables such as description or Author


例如我$ 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();


Add a Platform to a Plugin


$ plugman platform add --platform_name <platform>


Parameters:


  • <platform>: One of android, ios


必须在 cd platform directory 该级目录后操作


Add a Package.JSON file to plugin


Creates a package.json file in the plugin based on values from plugin.xml.

$ plugman createpackagejson <directory>


Building a Plugin 构建插件


想这样


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.


Usage


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


Optional flags


--debug|-d    : Verbose mode


Install a plugin

$ plugman install --platform <platform> --project <directory> --plugin <plugin> [--variable NAME=VALUE]


Parameters:


  • platform <platform>: One of android, ios, blackberry10, wp8, or windows8
  • project <directory>: Path reference to a cordova-generated project of the platform you specify


  • plugin <plugin>: One of a path reference to a local copy of a plugin, or a remote https: or git: URL pointing to a cordova plugin (optionally append #branch:subdir) or a plugin ID from http://plugins.cordova.io


  • variable NAME=VALUE: Some plugins require install-time variables to be defined. These could be things like API keys/tokens or other app-specific variables.


Optional parameters:


  • www <directory>: www assets for the plugin will be installed into this directory. Default is to install into the standard www directory for the platform specified
  • plugins_dir <directory>: a copy of the plugin will be stored in this directory. Default is to install into the <project directory>/plugins folder


  • searchpath <directory>: when looking up plugins by ID, look in this directory and each of its subdirectories for the plugin before hitting the registry.
    Multiple search paths can be used by either specifying the flag multiple times, or by separating paths with a delimiter (: on 'nix, ; on Windows).


卸载 plugin


$ plugman uninstall --platform <platform> --project <directory> --plugin <plugin-id>


Parameters:


  • platform <platform>: One of android, ios, blackberry10, wp8, or windows8


  • project <directory>: Path reference to a cordova-generated project of the platform you specify


  • plugin <plugin-id>: The plugin to remove, identified by its id (see the plugin.xml's <plugin id> attribute)


Interacting with the registry


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


Search for a plugin

$ plugman search <keyword1 keyword2 ...>


Display plugin information

$ plugman info <pluginID>


Manage registry configuration


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


Manage Owners


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


Create A Plugin

$ plugman create --name <pluginName> --plugin_id <pluginID> --plugin_version <version> [--path <directory>] [--variable NAME=VALUE]


Parameters:


  • <pluginName>: The name of the plugin


  • <pluginID>: An ID for the plugin, ex: org.bar.foo


  • <version>: A version for the plugin, ex: 0.0.1


  • <directory>: An absolute or relative path for the directory where the plugin project will be created


  • variable NAME=VALUE: Extra variables such as description or Author


Add a Package.JSON file to plugin


Creates a package.json file in the plugin based on values from plugin.xml.


$ plugman createpackagejson <directory>


Add a Platform to a Plugin

$ plugman platform add --platform_name <platform>


Parameters:


  • <platform>: One of android, ios


Remove a Platform from a Plugin

$ plugman platform remove --platform_name <platform>


Parameters:


  • <platform>: One of android, ios


目录
相关文章
|
1天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8057 2
|
10天前
|
域名解析 人工智能 Linux
|
20天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
18267 63
|
18天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
4天前
|
人工智能 安全 网络安全
|
2天前
|
人工智能 弹性计算 安全
阿里云 码上2027 AI coding 嘉年华
阿里云“码上2027”AI Coding嘉年华于2026年12月2—3日在上海西岸艺术中心举行,聚焦AI Coding从单点提效迈向企业级研发体系升级。发布Qwen4-max模型、QBot智能协作、AgentCore平台等重磅成果,并推出ECS云服务器特惠(200Mbps流量月付40元起)。
774 0
|
8天前
|
云安全 数据采集 人工智能
|
9天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是 DeepSeek AI 开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、执行命令、处理表格等自动化任务;免费开源,兼容 Win/macOS,需配 API 密钥使用。(239字)
1476 5
|
15天前
|
人工智能 开发工具 开发者
2026最新codex下载安装保姆级使用教程(下载+安装+登录+使用,含所有历史版本)
Codex 是 OpenAI 推出的开源 AI 编程智能体,跑在本地终端和桌面客户端里,能读懂整个代码仓库,一句自然语言就能让它改代码、执行命令、跑测试、修 Bug,支持 Windows、macOS、Linux 三大平台。本文把 Codex下载、安装、登录、汉化、基础使用一次讲全,并整理了国内用户最常踩的坑,跟着做 10 分钟就能跑起来。
2606 8
|
20天前
|
弹性计算 人工智能 API
Codex超详细入门指南(下载·安装·登录·上手,全版本覆盖,2026最新版)
建议收藏本教程,2026 全年各版本更新随时回来查阅。如果你在搭建过程中遇到任何问题,欢迎结合 阿里云工单系统 提交技术支持请求,或在 阿里云开发者社区 搜索 Codex 相关话题交流。 祝你编码愉快,效率翻倍!
4073 22