You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/05/22 20:30:23 UTC

git commit: Whole bunch of debugging output and not quite working

Updated Branches:
  refs/heads/git_refs [created] 03214e7cb


Whole bunch of debugging output and not quite working

Fails saying that a file already exists. I think it's copying assets
twice due to a bug in the dependency handling.


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

Branch: refs/heads/git_refs
Commit: 03214e7cb7fce9e9d0c65b1dc359f6eadc8a2463
Parents: 0ecc53a
Author: Braden Shepherdson <br...@gmail.com>
Authored: Wed May 22 14:29:30 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Wed May 22 14:29:30 2013 -0400

----------------------------------------------------------------------
 src/fetch.js             |    9 +++++++++
 src/install.js           |   17 +++++++++++++----
 src/platforms/common.js  |   17 ++++++++++++++++-
 src/util/action-stack.js |    1 +
 src/util/plugins.js      |    1 +
 5 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03214e7c/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index a222af6..de38d9a 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -20,13 +20,21 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, git
             plugins.clonePluginGitRepo(plugin_dir, plugins_dir, subdir, git_ref, callback);
         }
     } else {
+        if (plugin_dir.lastIndexOf('file://', 0) === 0) {
+            plugin_dir = plugin_dir.substring('file://'.length);
+        }
+
         // Copy from the local filesystem.
         // First, read the plugin.xml and grab the ID.
+        console.log('top', plugin_dir);
         plugin_dir = path.join(plugin_dir, subdir);
+        console.log('2');
         var xml = xml_helpers.parseElementtreeSync(path.join(plugin_dir, 'plugin.xml'));
+        console.log('3');
         var plugin_id = xml.getroot().attrib.id;
 
         var dest = path.join(plugins_dir, plugin_id);
+        console.log('4');
 
         shell.rm('-rf', dest);
         if (link) {
@@ -34,6 +42,7 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, git
         } else {
             shell.mkdir('-p', dest);
             shell.cp('-R', path.join(plugin_dir, '*') , dest);
+            console.log('5');
         }
 
         if (callback) callback(null, dest);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03214e7c/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 9a1ea36..33a95a1 100644
--- a/src/install.js
+++ b/src/install.js
@@ -7,6 +7,7 @@ var path = require('path'),
     platform_modules = require('./platforms');
 
 module.exports = function installPlugin(platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, callback) {
+    console.log('===========\n\nwww_dir = ' + www_dir + '\n\n==================');
     if (!platform_modules[platform]) {
         var err = new Error(platform + " not supported.");
         if (callback) callback(err);
@@ -16,17 +17,20 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
 
     var current_stack = new action_stack();
 
-    possiblyFetch(current_stack, platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, true, callback);
+    possiblyFetch(current_stack, platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, undefined /* git_ref */, true, callback);
 };
 
-function possiblyFetch(actions, platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, is_top_level, callback) {
+function possiblyFetch(actions, platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, git_ref, is_top_level, callback) {
+    console.log('f1');
+    console.log(plugins_dir, id);
     var plugin_dir = path.join(plugins_dir, id);
+    console.log('f2');
 
     // Check that the plugin has already been fetched.
     if (!fs.existsSync(plugin_dir)) {
         // if plugin doesnt exist, use fetch to get it.
         // TODO: Actual value for git_ref.
-        require('../plugman').fetch(id, plugins_dir, false, '.', undefined /* git_ref */, function(err, plugin_dir) {
+        require('../plugman').fetch(id, plugins_dir, false, '.', git_ref, function(err, plugin_dir) {
             if (err) {
                 callback(err);
             } else {
@@ -95,6 +99,7 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli
             var dep_plugin_id = dep.attrib.id;
             var dep_subdir = dep.attrib.subdir;
             var dep_url = dep.attrib.url;
+            var dep_git_ref = dep.attrib.commit;
             if (dep_subdir) {
                 dep_subdir = path.join.apply(null, dep_subdir.split('/'));
             }
@@ -104,7 +109,11 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli
                 runInstall(actions, platform, project_dir, dep_plugin_dir, plugins_dir, filtered_variables, www_dir, false, end);
             } else {
                 console.log('Dependent plugin ' + dep_plugin_id + ' not fetched, retrieving then installing.');
-                possiblyFetch(actions, platform, project_dir, dep_url, plugins_dir, dep_subdir, filtered_variables, www_dir, false, end);
+                try {
+                    possiblyFetch(actions, platform, project_dir, dep_url, plugins_dir, dep_subdir, filtered_variables, www_dir, dep_git_ref, false, end);
+                } catch (e) {
+                    console.log(e);
+                }
             }
         });
     } else {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03214e7c/src/platforms/common.js
----------------------------------------------------------------------
diff --git a/src/platforms/common.js b/src/platforms/common.js
index d4ee21d..09d68d3 100644
--- a/src/platforms/common.js
+++ b/src/platforms/common.js
@@ -13,12 +13,14 @@ module.exports = {
     // helper for resolving target paths from plugin.xml into a cordova project
     // throws File Exists
     resolveTargetPath:function(project_dir, relative_path) {
+        console.log('resolveTargetPath', project_dir, relative_path);
         var full_path = path.resolve(project_dir, relative_path);
         if (fs.existsSync(full_path)) throw new Error('"' + full_path + '" already exists!');
         else return full_path;
     },
     // Many times we simply need to copy shit over, knowing if a source path doesnt exist or if a target path already exists
     copyFile:function(plugin_dir, src, project_dir, dest) {
+        console.log('copyFile', plugin_dir, src, project_dir, dest);
         src = module.exports.resolveSrcPath(plugin_dir, src);
         dest = module.exports.resolveTargetPath(project_dir, dest);
         shell.mkdir('-p', path.dirname(dest));
@@ -61,10 +63,23 @@ module.exports = {
         install:function(asset_el, plugin_dir, www_dir) {
             var src = asset_el.attrib.src;
             var target = asset_el.attrib.target;
+
+            if (!src) {
+                throw new Error('<asset> tag without required "src" attribute');
+            }
+            if (!target) {
+                throw new Error('<asset> tag without required "target" attribute');
+            }
+
             module.exports.copyFile(plugin_dir, src, www_dir, target);
         },
         uninstall:function(asset_el, www_dir, plugin_id) {
-            var target = asset_el.attrib.target;
+            var target = asset_el.attrib.target || asset_el.attrib.src;
+
+            if (!target) {
+                throw new Error('<asset> tag without required "target" attribute');
+            }
+
             module.exports.removeFile(www_dir, target);
             module.exports.removeFileF(path.resolve(www_dir, 'plugins', plugin_id));
         }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03214e7c/src/util/action-stack.js
----------------------------------------------------------------------
diff --git a/src/util/action-stack.js b/src/util/action-stack.js
index e3b63d8..e4a9460 100644
--- a/src/util/action-stack.js
+++ b/src/util/action-stack.js
@@ -54,6 +54,7 @@ ActionStack.prototype = {
                         issue += 'A reversion action failed: ' + err.message + '\n';
                     }
                 }
+                console.log(e.stack);
                 e.message = issue + e.message;
                 if (callback) callback(e);
                 else throw e;

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03214e7c/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index f1b3f0b..7fda99b 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -37,6 +37,7 @@ module.exports = {
             else throw err;
         }
 
+        console.log('clonePluginGitRepo', plugin_git_url, plugins_dir, subdir, git_ref);
         shell.rm('-rf', tmp_dir);
 
         var cmd = util.format('git clone "%s" "%s"', plugin_git_url, tmp_dir);