使用 Plugman 來管理外掛程式


license: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations

under the License.

使用 Plugman 來管理外掛程式

從 3.0 版本開始,科爾多瓦實現所有設備 Api 作為外掛程式,然後留在預設情況下禁用。 此外,它還支援兩種不同的方法來添加和刪除外掛程式,根據您的工作流概述中討論的選擇:

本節詳細介紹的 Plugman 實用程式。 消費作為節點模組 Plugman 或修改的原始程式碼的詳細資訊,請參閱其庫中的讀我檔案.

安裝 Plugman

要安裝 plugman,您必須在您的機器上安裝的節點。 然後您可以運行下面的命令從任意位置在您的環境以全域,安裝 plugman,這樣就可從任何目錄中:

$ npm install -g plugman

您還必須有有 git 上你 PATH ,以便能夠直接從遠端 git Url 安裝的外掛程式。

提示: 如果您在安裝與 plugman 後發現 npm 你是仍然不能運行任何 plugman 的命令,請確保您已添加 /npm/ 目錄到您PATH.

: 您可以跳過此步驟,如果你不想污染您的全球性 npm 通過全球範圍內安裝 Plugman 的命名空間。 如果這種情況,然後當你與外殼工具創建科爾多瓦專案,將有 node_modules 目錄裡面您的專案包含 Plugman。 由於全球範圍內你沒有安裝,您需要調用 node 的每個 Plugman 命令,例如 node ./node_modules/plugman/main.js -version 。 本指南的其餘部分假定您已安裝 Plugman 就全球而言,意味著您可以調用它與只是plugman.

創建一個專案,科爾多瓦

您可以使用 Plugman 之前,您必須創建一個科爾多瓦專案。 你可以用命令列介面或更低的級別的 shell 腳本。 使用 shell 腳本來創建您的專案的說明都位於平臺指南頁上列出的各項"命令列工具"指南。

添加外掛程式

一旦你已經安裝了 Plugman,並已創建一個科爾多瓦專案,您可以開始將外掛程式添加到與平臺:

$ plugman --platform <ios|amazon-fireos|android|blackberry10|wp8> --project <directory> --plugin <name|url|path> [--plugins_dir <directory>] [--www <directory>] [--variable <name>=<value> [--variable <name>=<value> ...]]

使用最小的參數,此命令將外掛程式安裝到科爾多瓦的一個專案。 您必須指定一個為該平臺的平臺和科爾多瓦的專案位置。 此外必須指定與不同的外掛程式, --plugin 參數形式是:

其他參數:

刪除某個外掛程式

若要卸載外掛程式,你只需通過 --uninstall 標記,並提供外掛程式 id。

$ plugman --uninstall --platform <ios|amazon-fireos|android|blackberry10|wp8> --project <directory> --plugin <id> [--www <directory>] [--plugins_dir <directory>]

説明命令

Plugman 特色全球説明命令,可以説明你如果你卡住或遇到的問題。它將顯示所有可用的 Plugman 命令和它們的語法的清單:

plugman -help
plugman  # same as above

plugman -help 可能會顯示一些額外的與註冊表相關的命令。 這些命令用於外掛程式開發人員,不可能進行協力廠商外掛程式登記處。

您還可以將追加 --debug|-d 旗子到任何 Plugman 命令以運行該命令以詳細模式,將顯示任何內部調試消息,因為他們排放和可説明您跟蹤下像缺少檔的問題。

# Adding Android battery-status plugin to "myProject":
plugman -d --platform android --project myProject --plugin org.apache.cordova.battery-status

最後,您可以使用 --version|-v 標誌來查看您使用哪個版本的 Plugman。

plugman -v

註冊表操作

那裡有很多的 plugman 命令,可以用於與外掛程式註冊表進行交互。 請注意這些註冊表命令是特定于plugins.cordova.io外掛程式註冊表,不可能由協力廠商外掛程式登記處執行。

尋找一個外掛程式

您可以使用 Plugman 來搜索外掛程式註冊表外掛程式 id 的匹配給定以空格分隔的關鍵字清單。

plugman search <plugin keywords>

更改外掛程式註冊表

您可以獲取或設置當前外掛程式註冊表的 URL,使用的 plugman。通常你應該離開這在 HTTP://registry.cordova.io 設置,除非您想要使用協力廠商外掛程式註冊表。

plugman config set registry <url-to-registry>
plugman config get registry

獲取外掛程式的資訊

您可以獲得有關任何特定外掛程式在外掛程式庫中存儲的資訊:

plugman info <id>

這將聯繫的外掛程式註冊表和提取資訊,如外掛程式的版本編號。

安裝核心外掛程式

下面的示例顯示如何添加外掛程式,如需要,這樣您在您的專案中使用任何科爾多瓦 Api 仍然工作後你升級到 3.0 版本。對於每個命令,你需要選擇目標平臺,並引用該平臺的專案目錄。