cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject git commit: Rewire commands: Split into --fetch, --install, --uninstall, --remove.
Date Tue, 26 Mar 2013 16:06:06 GMT
Updated Branches:
  refs/heads/future 57f92736e -> dde313cbc


Rewire commands: Split into --fetch, --install, --uninstall, --remove.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/dde313cb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/dde313cb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/dde313cb

Branch: refs/heads/future
Commit: dde313cbcfd5073707dd5b9a7d0caf66ed981b16
Parents: 57f9273
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Tue Mar 26 12:05:31 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Tue Mar 26 12:05:31 2013 -0400

----------------------------------------------------------------------
 plugman.js |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/dde313cb/plugman.js
----------------------------------------------------------------------
diff --git a/plugman.js b/plugman.js
index 7e6e52b..ad4be96 100755
--- a/plugman.js
+++ b/plugman.js
@@ -39,6 +39,9 @@ var known_opts = { 'platform' : [ 'ios', 'android', 'bb10' ,'www' ]
             , 'project' : path
             , 'plugin' : [String, path, url]
             , 'remove' : Boolean
+            , 'install' : Boolean
+            , 'uninstall' : Boolean
+            , 'fetch' : Boolean
             , 'list' : Boolean
             , 'v' : Boolean
             , 'debug' : Boolean
@@ -81,10 +84,16 @@ else if (cli_opts.list) {
 else if (cli_opts.prepare && cli_opts.project && cli_opts.www) {
     plugin_loader.handlePrepare(cli_opts.project, plugins_dir, cli_opts.www, cli_opts.platform);
 }
+else if (cli_opts.remove) {
+    removePlugin(cli_opts.plugin);
+}
+else if (cli_opts.fetch) {
+    fetchPlugin(cli_opts.plugin);
+}
 else if (!cli_opts.platform || !cli_opts.project || !cli_opts.plugin) {
     printUsage();
 }
-else if (cli_opts.remove) {
+else if (cli_opts.uninstall) {
     handlePlugin('uninstall', cli_opts.platform, cli_opts.project, cli_opts.plugin);
 }
 else {
@@ -94,11 +103,13 @@ else {
 function printUsage() {
     platforms = known_opts.platform.join('|');
     console.log('Usage\n---------');
-    console.log('Add a plugin:\n\t' + package.name + ' --platform <'+ platforms +'>
--project <directory> --plugin <directory|git-url|name>\n');
-    console.log('Remove a plugin:\n\t' + package.name + ' --remove --platform <'+ platforms
+'> --project <directory> --plugin <directory|git-url|name>\n');
-    console.log('List plugins:\n\t' + package.name + ' --list\n');
+    console.log('Fetch a plugin:\n\t' + package.name + ' --fetch --plugin <directory|git-url|name>
[--plugins_dir <directory>]\n');
+    console.log('Install an already fetched plugin:\n\t' + package.name + ' --platform <'+
platforms +'> --project <directory> --plugin <name> [--plugins_dir <directory>]\n');
+    console.log('Uninstall a plugin:\n\t' + package.name + ' --remove --platform <'+ platforms
+'> --project <directory> --plugin <name> [--plugins_dir <directory>]\n');
+    console.log('Delete the local copy of a plugin:\n\t' + package.name + ' --remove --plugin
<name> [--plugins_dir <directory>]\n');
+    console.log('List plugins:\n\t' + package.name + ' --list [--plugins_dir <directory>]\n');
     console.log('Prepare project:\n\t' + package.name + ' --prepare --platform <ios|android|bb10>
--project <directory> --www <directory> [--plugins_dir <directory>]');
-    console.log('\n\t--plugins_dir defaults to <project>/cordova/plugins, but can be
any directory containing a subdirectory for each plugin');
+    console.log('\n--plugins_dir defaults to <project>/cordova/plugins, but can be
any directory containing a subdirectory for each plugin');
 }
 
 function execAction(action, platform, project_dir, plugin_dir) {
@@ -112,9 +123,7 @@ function execAction(action, platform, project_dir, plugin_dir) {
     console.log('plugin ' + action + 'ed');
 }
 
-function handlePlugin(action, platform, project_dir, plugin_dir) {
-    var plugin_xml_path, async = false;
-
+function fetchPlugin(plugin_dir) {
     // Ensure the containing directory exists.
     shell.mkdir('-p', plugins_dir);
 
@@ -134,6 +143,21 @@ function handlePlugin(action, platform, project_dir, plugin_dir) {
 
         plugin_dir = dest;
     }
+}
+
+function removePlugin(name) {
+    shell.rm('-rf', path.join(plugins_dir, cli_opts.plugin));
+    console.log('Plugin ' + cli_opts.plugin + ' deleted.');
+}
+
+function handlePlugin(action, platform, project_dir, name) {
+    var plugin_xml_path, async;
+
+    // Check that the plugin has already been fetched.
+    var plugin_dir = path.join(plugins_dir, name);
+    if (!fs.existsSync(plugin_dir)) {
+        throw new Error('Plugin ' + name + ' not found. You may need to --fetch it.');
+    }
 
     plugin_xml_path = path.join(plugin_dir, 'plugin.xml');
     if (!fs.existsSync(plugin_xml_path)) {
@@ -141,7 +165,7 @@ function handlePlugin(action, platform, project_dir, plugin_dir) {
         async = true;
         plugins.getPluginInfo(plugin_dir,
             function(plugin_info) {
-                execAction(action, platform, project_dir, plugins.clonePluginGitRepo(plugin_info.url));
+                execAction(action, platform, project_dir, plugins.clonePluginGitRepo(plugin_info.url),
plugins_dir);
             },
             function(e) {
                 throw new Error(action + ' failed. "' + plugin_xml_path + '" not found');


Mime
View raw message