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/23 19:38:54 UTC

[1/4] git commit: Whole bunch of debugging output and not quite working

Updated Branches:
  refs/heads/master 0ecc53af2 -> 4741f93c2


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/master
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);


[4/4] git commit: Fix handling of git revisions when fetching dependencies

Posted by br...@apache.org.
Fix handling of git revisions when fetching dependencies


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

Branch: refs/heads/master
Commit: 4741f93c2c988a18751f15e98c333b5708b4c66c
Parents: daec2d4
Author: Braden Shepherdson <br...@gmail.com>
Authored: Thu May 23 13:32:19 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Thu May 23 13:38:39 2013 -0400

----------------------------------------------------------------------
 src/platforms/common.js |    2 -
 src/util/plugins.js     |   61 +++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/4741f93c/src/platforms/common.js
----------------------------------------------------------------------
diff --git a/src/platforms/common.js b/src/platforms/common.js
index 09d68d3..0e602c1 100644
--- a/src/platforms/common.js
+++ b/src/platforms/common.js
@@ -13,14 +13,12 @@ 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));

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/4741f93c/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 4f532d4..07c5d95 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -39,40 +39,41 @@ module.exports = {
 
         shell.rm('-rf', tmp_dir);
 
-        var cmd = util.format('git clone "%s" "%s"', plugin_git_url, tmp_dir);
-        shell.exec(cmd, {silent: true, async:true}, function(code, output) {
-            if (code > 0) {
-                var err = new Error('failed to get the plugin via git from URL '+ plugin_git_url + ', output: ' + output);
-                if (callback) callback(err)
-                else throw err;
-            } else {
-                console.log('Plugin "' + plugin_git_url + '" fetched.');
-                // Check out the specified revision, if provided.
-                if (git_ref) {
-                    var cmd = util.format('cd "%s" && git checkout "%s"', tmp_dir, git_ref);
-                    var result = shell.exec(cmd, { silent: true, async:false });
-                    if (result.code > 0) {
-                        var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '", output: ' + result.output);
-                        if (callback) callback(err);
-                        else throw err;
-                    }
+        shell.cd(path.dirname(tmp_dir));
+        var cmd = util.format('git clone "%s" "%s"', plugin_git_url, path.basename(tmp_dir));
+        var result = shell.exec(cmd, {silent: true, async:false});
+        if (result.code > 0) {
+            var err = new Error('failed to get the plugin via git from URL '+ plugin_git_url + ', output: ' + result.output);
+            if (callback) callback(err)
+            else throw err;
+        } else {
+            console.log('Plugin "' + plugin_git_url + '" fetched.');
+            // Check out the specified revision, if provided.
+            if (git_ref) {
+                var cmd = util.format('cd "%s" && git checkout "%s"', tmp_dir, git_ref);
+                var result = shell.exec(cmd, { silent: true, async:false });
+                if (result.code > 0) {
+                    var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '", output: ' + result.output);
+                    if (callback) callback(err);
+                    else throw err;
                 }
+                console.log('Checked out ' + git_ref);
+            }
 
-                // Read the plugin.xml file and extract the plugin's ID.
-                tmp_dir = path.join(tmp_dir, subdir);
-                // TODO: what if plugin.xml does not exist?
-                var xml_file = path.join(tmp_dir, 'plugin.xml');
-                var xml = xml_helpers.parseElementtreeSync(xml_file);
-                var plugin_id = xml.getroot().attrib.id;
+            // Read the plugin.xml file and extract the plugin's ID.
+            tmp_dir = path.join(tmp_dir, subdir);
+            // TODO: what if plugin.xml does not exist?
+            var xml_file = path.join(tmp_dir, 'plugin.xml');
+            var xml = xml_helpers.parseElementtreeSync(xml_file);
+            var plugin_id = xml.getroot().attrib.id;
 
-                // TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
-                // should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
-                var plugin_dir = path.join(plugins_dir, plugin_id);
-                shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
+            // TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
+            // should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
+            var plugin_dir = path.join(plugins_dir, plugin_id);
+            shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
 
-                if (callback) callback(null, plugin_dir);
-            }
-        });
+            if (callback) callback(null, plugin_dir);
+        }
     }
 };
 


[3/4] git commit: cd into the cloned git repo before running git checkout.

Posted by br...@apache.org.
cd into the cloned git repo before running git checkout.


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

Branch: refs/heads/master
Commit: daec2d4d817653e6ee4a1c8c6b711f4e12e925e8
Parents: a79a75e
Author: Fil Maj <ma...@gmail.com>
Authored: Wed May 22 13:05:16 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed May 22 13:05:16 2013 -0700

----------------------------------------------------------------------
 src/install.js      |    1 +
 src/util/plugins.js |    6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/daec2d4d/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 89bd034..6f70c4c 100644
--- a/src/install.js
+++ b/src/install.js
@@ -119,6 +119,7 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli
 }
 
 function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_basename, plugin_dir, filtered_variables, www_dir, is_top_level, callback) {
+    console.log('Installing plugin ' + plugin_id + '...');
     var handler = platform_modules[platform];
     www_dir = www_dir || handler.www_dir(project_dir);
 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/daec2d4d/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index f8b2846..4f532d4 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -46,11 +46,13 @@ module.exports = {
                 if (callback) callback(err)
                 else throw err;
             } else {
+                console.log('Plugin "' + plugin_git_url + '" fetched.');
                 // Check out the specified revision, if provided.
                 if (git_ref) {
-                    var result = shell.exec(util.format('git checkout "%s"', git_ref), { silent: true });
+                    var cmd = util.format('cd "%s" && git checkout "%s"', tmp_dir, git_ref);
+                    var result = shell.exec(cmd, { silent: true, async:false });
                     if (result.code > 0) {
-                        var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '"');
+                        var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '", output: ' + result.output);
                         if (callback) callback(err);
                         else throw err;
                     }


[2/4] git commit: removed debuggin statements. fix for proper handling of fetch callback to check for errors before triggering main plugin handling.

Posted by br...@apache.org.
removed debuggin statements. fix for proper handling of fetch callback to check for errors before triggering main plugin 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/a79a75e1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/a79a75e1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/a79a75e1

Branch: refs/heads/master
Commit: a79a75e1fee41e58c0bd29a94556507a06411405
Parents: 03214e7
Author: Fil Maj <ma...@gmail.com>
Authored: Wed May 22 12:49:20 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed May 22 12:49:20 2013 -0700

----------------------------------------------------------------------
 src/fetch.js        |    5 -----
 src/install.js      |   15 ++++++---------
 src/util/plugins.js |    3 +--
 3 files changed, 7 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a79a75e1/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index de38d9a..e58ef00 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -26,15 +26,11 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, git
 
         // 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) {
@@ -42,7 +38,6 @@ 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/a79a75e1/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 33a95a1..89bd034 100644
--- a/src/install.js
+++ b/src/install.js
@@ -7,7 +7,6 @@ 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);
@@ -21,10 +20,7 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
 };
 
 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)) {
@@ -109,11 +105,12 @@ 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.');
-                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);
-                }
+                possiblyFetch(actions, platform, project_dir, dep_url, plugins_dir, dep_subdir, filtered_variables, www_dir, dep_git_ref, false, function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else end();
+                });
             }
         });
     } else {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a79a75e1/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 7fda99b..f8b2846 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -37,7 +37,6 @@ 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);
@@ -51,7 +50,7 @@ module.exports = {
                 if (git_ref) {
                     var result = shell.exec(util.format('git checkout "%s"', git_ref), { silent: true });
                     if (result.code > 0) {
-                        var err = new Error('failed to checkout git ref "' + git_ref + '"');
+                        var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '"');
                         if (callback) callback(err);
                         else throw err;
                     }