You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/07/09 23:10:54 UTC

[1/4] git commit: removed a console log

Updated Branches:
  refs/heads/CB-4077 [created] 2b70e6b7d


removed a console log


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

Branch: refs/heads/CB-4077
Commit: f4ffadcf97cf2fea3544a43aa1a4e61fbffea2ab
Parents: a13d5f5
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jul 9 12:40:38 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Jul 9 12:40:38 2013 -0700

----------------------------------------------------------------------
 spec/util/csproj.spec.js | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/f4ffadcf/spec/util/csproj.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/csproj.spec.js b/spec/util/csproj.spec.js
index fb66f6c..a75b68b 100644
--- a/spec/util/csproj.spec.js
+++ b/spec/util/csproj.spec.js
@@ -39,7 +39,6 @@ describe('csproj', function() {
 
             it('should properly add .xaml files', function() {
                 test_csproj.addSourceFile(page_test);
-                console.log(test_csproj.xml.getroot().findall('.//Page'));
                 expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]')).toBeTruthy();        
                 expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]/Generator').text).toEqual('MSBuild:Compile');
                 expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]/SubType').text).toEqual('Designer');


[4/4] git commit: Work for [CB-4077]: uninstallation should look at platform json file for determining which plugins to iterate over. fetching multiple plugins from git should not collide in temp dir.

Posted by fi...@apache.org.
Work for [CB-4077]: uninstallation should look at platform json file for determining which plugins to iterate over. fetching multiple plugins from git should not collide in temp dir.


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

Branch: refs/heads/CB-4077
Commit: 2b70e6b7d29c4f5ee5facd4872264a6af19470de
Parents: 03e8349
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jul 9 14:10:48 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Jul 9 14:10:48 2013 -0700

----------------------------------------------------------------------
 spec/prepare.spec.js | 7 +++----
 src/install.js       | 6 ++----
 src/prepare.js       | 8 +++-----
 src/util/plugins.js  | 6 +++---
 4 files changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2b70e6b7/spec/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/prepare.spec.js b/spec/prepare.spec.js
index 675444a..5bf51ff 100644
--- a/spec/prepare.spec.js
+++ b/spec/prepare.spec.js
@@ -15,12 +15,12 @@ var json = path.join(temp, 'assets', 'www', 'cordova_plugins.json');
 var js = path.join(temp, 'assets', 'www', 'cordova_plugins.js');
 
 describe('prepare', function() {
-    var proc, readdir, write, stat, read, parseET, mkdir;
+    var proc, platform_json, write, stat, read, parseET, mkdir;
     var root, findall, find;
     beforeEach(function() {
         mkdir = spyOn(shell, 'mkdir');
         proc = spyOn(config_changes, 'process');
-        readdir = spyOn(fs, 'readdirSync').andReturn([]);
+        platform_json = spyOn(config_changes, 'get_platform_json').andReturn({installed_plugins:{},dependent_plugins:{}});
         write = spyOn(fs, 'writeFileSync');
         stat = spyOn(fs, 'statSync').andReturn({isDirectory:function() { return true; }});
         root = jasmine.createSpy('ElementTree getroot').andReturn({
@@ -46,11 +46,10 @@ describe('prepare', function() {
     });
     describe('handling of js-modules', function() {
         var read, child_one;
-        var fake_plugins = ['plugin_one', 'plugin_two'];
         beforeEach(function() {
             child_one = jasmine.createSpy('getchildren').andReturn([]);
             read = spyOn(fs, 'readFileSync').andReturn('JAVASCRIPT!');
-            readdir.andReturn(fake_plugins);
+            platform_json.andReturn({installed_plugins:{plugin_one:'',plugin_two:''},dependent_plugins:{}});
             findall.andReturn([
                 {attrib:{src:'somedir', name:'NAME'}, getchildren:child_one},
                 {attrib:{src:'someotherdir', name:'NAME'}, getchildren:child_one}

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2b70e6b7/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 2c2c025..3868ccf 100644
--- a/src/install.js
+++ b/src/install.js
@@ -184,14 +184,12 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
                     var result = shell.exec('git rev-parse --show-toplevel', { silent:true, async:false});
                     if (result.code === 128) {
                         var err = new Error('Error: Plugin ' + plugin_id + ' is not in git repository. All plugins must be in a git repository.');
-                        if (callback) callback(err);
+                        if (callback) return callback(err);
                         else throw err;
-                        return;
                     } else if(result.code > 0) {
                         var err = new Error('Error trying to locate git repository for plugin.');
-                        if (callback) callback(err);
+                        if (callback) return callback(err);
                         else throw err;
-                        return;
                     }
 
                     var dep_url = path.join(result.output.trim(), dep_subdir);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2b70e6b7/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 4904975..f898b84 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -46,14 +46,12 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir) {
     config_changes.process(plugins_dir, project_dir, platform);
 
     var wwwDir = platform_modules[platform].www_dir(project_dir);
-    // TODO: perhaps this should look at platform json files to determine which plugins to prepare?
-    var plugins = fs.readdirSync(plugins_dir).filter(function(p) {
-        return p != '.svn' && p != 'CVS';
-    });
+    var platform_json = config_changes.get_platform_json(plugins_dir, platform);
+    var plugins = Object.keys(platform_json.installed_plugins).concat(Object.keys(platform_json.dependent_plugins));
 
     // This array holds all the metadata for each module and ends up in cordova_plugins.json
     var moduleObjects = [];
-    require('../plugman').emit('log', 'Iterating over installed plugins...');
+    require('../plugman').emit('log', 'Iterating over installed plugins:', plugins);
 
     plugins && plugins.forEach(function(plugin) {
         var pluginDir = path.join(plugins_dir, plugin);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2b70e6b7/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 90b24f7..7153926 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -23,8 +23,7 @@ var http = require('http'),
     fs = require('fs'),
     util = require('util'),
     shell = require('shelljs'),
-    xml_helpers = require('./xml-helpers'),
-    tmp_dir = path.join(os.tmpdir(), 'plugman-tmp');
+    xml_helpers = require('./xml-helpers');
 
 module.exports = {
     searchAndReplace:require('./search-and-replace'),
@@ -35,6 +34,7 @@ module.exports = {
             if (callback) return callback(err);
             else throw err;
         }
+        var tmp_dir = path.join(os.tmpdir(), 'plugman-tmp' +(new Date).valueOf());
 
         shell.rm('-rf', tmp_dir);
 
@@ -69,8 +69,8 @@ module.exports = {
 
                 // 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.
-                require('../../plugman').emit('log', 'Copying fetched plugin over "' + plugin_dir + '"...');
                 var plugin_dir = path.join(plugins_dir, plugin_id);
+                require('../../plugman').emit('log', 'Copying fetched plugin over "' + plugin_dir + '"...');
                 shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
 
                 require('../../plugman').emit('log', 'Plugin "' + plugin_id + '" fetched.');


[3/4] git commit: [CB-4077] Fix tests for cordova-cli, properly uninstall plugin source

Posted by fi...@apache.org.
[CB-4077] Fix tests for cordova-cli, properly uninstall plugin source


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

Branch: refs/heads/CB-4077
Commit: 03e83498944bf9362d149981eba155929e871e15
Parents: 05797d0
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Jul 8 14:26:40 2013 -0400
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Jul 9 12:41:29 2013 -0700

----------------------------------------------------------------------
 spec/uninstall.spec.js | 96 ++++++++++++++++++++++++++++++++++++++++++++-
 src/uninstall.js       |  2 +-
 2 files changed, 95 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03e83498/spec/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/spec/uninstall.spec.js b/spec/uninstall.spec.js
index 61e1c81..aca4e7c 100644
--- a/spec/uninstall.spec.js
+++ b/spec/uninstall.spec.js
@@ -15,6 +15,98 @@ var uninstall = require('../src/uninstall'),
     engineplugin = 'EnginePlugin',
     plugins_dir = path.join(temp, 'plugins');
 
+describe('uninstallPlatform', function() {
+    var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
+    beforeEach(function() {
+        proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb) {
+            cb();
+        });
+        actions_push = spyOn(actions.prototype, 'push');
+        c_a = spyOn(actions.prototype, 'createAction');
+        prepare = spyOn(plugman, 'prepare');
+        exec = spyOn(shell, 'exec').andReturn({code:1});
+        chmod = spyOn(fs, 'chmodSync');
+        exists = spyOn(fs, 'existsSync').andReturn(true);
+        get_json = spyOn(config_changes, 'get_platform_json').andReturn({
+            installed_plugins:{},
+            dependent_plugins:{}
+        });
+        rm = spyOn(shell, 'rm');
+        add_to_queue = spyOn(config_changes, 'add_uninstalled_plugin_to_prepare_queue');
+    });
+    describe('success', function() {
+        it('should call prepare after a successful uninstall', function() {
+            uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+            expect(prepare).toHaveBeenCalled();
+        });
+        it('should call the config-changes module\'s add_uninstalled_plugin_to_prepare_queue method after processing an install', function() {
+            uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+            expect(add_to_queue).toHaveBeenCalledWith(plugins_dir, 'DummyPlugin', 'android', true);
+        });
+        it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
+            uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+            expect(actions_push.calls.length).toEqual(3);
+            expect(c_a).toHaveBeenCalledWith(jasmine.any(Function), [jasmine.any(Object), temp, dummy_id], jasmine.any(Function), [jasmine.any(Object), path.join(plugins_dir, dummyplugin), temp, dummy_id]);
+            expect(proc).toHaveBeenCalled();
+        });
+
+        describe('with dependencies', function() {
+            it('should uninstall "dangling" dependencies');
+            it('should not uninstall any dependencies that are relied on by other plugins');
+        });
+    });
+
+    describe('failure', function() {
+        it('should throw if platform is unrecognized', function() {
+            expect(function() {
+                uninstall.uninstallPlatform('atari', temp, 'SomePlugin', plugins_dir, {});
+            }).toThrow('atari not supported.');
+        });
+        it('should throw if plugin is missing', function() {
+            exists.andReturn(false);
+            expect(function() {
+                uninstall.uninstallPlatform('android', temp, 'SomePluginThatDoesntExist', plugins_dir, {});
+            }).toThrow('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?');
+        });
+    });
+});
+
+describe('uninstallPlugin', function() {
+    var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
+    beforeEach(function() {
+        proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb) {
+            cb();
+        });
+        actions_push = spyOn(actions.prototype, 'push');
+        c_a = spyOn(actions.prototype, 'createAction');
+        prepare = spyOn(plugman, 'prepare');
+        exec = spyOn(shell, 'exec').andReturn({code:1});
+        chmod = spyOn(fs, 'chmodSync');
+        exists = spyOn(fs, 'existsSync').andReturn(true);
+        get_json = spyOn(config_changes, 'get_platform_json').andReturn({
+            installed_plugins:{},
+            dependent_plugins:{}
+        });
+        rm = spyOn(shell, 'rm');
+        add_to_queue = spyOn(config_changes, 'add_uninstalled_plugin_to_prepare_queue');
+    });
+    describe('success', function() {
+        it('should remove the plugin directory', function() {
+            uninstall.uninstallPlugin(dummyplugin, plugins_dir);
+            expect(rm).toHaveBeenCalled();
+        });
+    });
+
+    describe('failure', function() {
+        it('should throw if plugin is missing', function() {
+            exists.andReturn(false);
+            expect(function() {
+                uninstall('android', temp, 'SomePluginThatDoesntExist', plugins_dir, {});
+            }).toThrow('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?');
+        });
+    });
+});
+
 describe('uninstall', function() {
     var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
     beforeEach(function() {
@@ -52,10 +144,10 @@ describe('uninstall', function() {
 
         describe('with dependencies', function() {
             it('should uninstall "dangling" dependencies');
-            it('should not uninstall any dependencies that are relied on by other plugins'); 
+            it('should not uninstall any dependencies that are relied on by other plugins');
         });
     });
-    
+
     describe('failure', function() {
         it('should throw if platform is unrecognized', function() {
             expect(function() {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/03e83498/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index 8728711..6d59e84 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -17,7 +17,7 @@ module.exports = function(platform, project_dir, id, plugins_dir, options, callb
             if (callback) return callback(err);
             else throw err;
         }
-        module.exports.uninstallPlugin(id, plugins_dir, options, callback);
+        module.exports.uninstallPlugin(id, plugins_dir, callback);
     });
 }
 


[2/4] git commit: [CB-4077] Separate the actions of removing a plugin from a platform and removing the plugin entirely

Posted by fi...@apache.org.
[CB-4077] Separate the actions of removing a plugin from a platform and removing the plugin entirely


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

Branch: refs/heads/CB-4077
Commit: 05797d0c7d4c801d1463445db0c37e0ae5d8a8af
Parents: f4ffadc
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Jul 5 10:49:04 2013 -0400
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Jul 9 12:41:29 2013 -0700

----------------------------------------------------------------------
 src/uninstall.js | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/05797d0c/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index dbe0fae..8728711 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -11,7 +11,17 @@ var path = require('path'),
     platform_modules = require('./platforms');
 
 // possible options: cli_variables, www_dir
-module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir, options, callback) {
+module.exports = function(platform, project_dir, id, plugins_dir, options, callback) {
+    module.exports.uninstallPlatform(platform, project_dir, id, plugins_dir, options, function(err) {
+        if (err) {
+            if (callback) return callback(err);
+            else throw err;
+        }
+        module.exports.uninstallPlugin(id, plugins_dir, options, callback);
+    });
+}
+
+module.exports.uninstallPlatform = function(platform, project_dir, id, plugins_dir, options, callback) {
     if (!platform_modules[platform]) {
         var err = new Error(platform + " not supported.");
         if (callback) return callback(err);
@@ -32,11 +42,21 @@ module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir
     runUninstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options, callback);
 };
 
+module.exports.uninstallPlugin = function(id, plugins_dir, callback) {
+    var plugin_dir = path.join(plugins_dir, id);
+    var xml_path     = path.join(plugin_dir, 'plugin.xml')
+      , plugin_et    = xml_helpers.parseElementtreeSync(xml_path);
+    var plugin_id    = plugin_et._root.attrib['id'];
+    // axe the directory
+    shell.rm('-rf', plugin_dir);
+    require('../plugman').emit('log', plugin_id + ' uninstalled.');
+    if (callback) callback();
+};
+
 // possible options: cli_variables, www_dir, is_top_level
 function runUninstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback) {
     var xml_path     = path.join(plugin_dir, 'plugin.xml')
       , plugin_et    = xml_helpers.parseElementtreeSync(xml_path);
-    var name         = plugin_et.findall('name').text;
     var plugin_id    = plugin_et._root.attrib['id'];
     options = options || {};
 
@@ -131,9 +151,6 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, w
             config_changes.add_uninstalled_plugin_to_prepare_queue(plugins_dir, path.basename(plugin_dir), platform, is_top_level);
             // call prepare after a successful uninstall
             require('./../plugman').prepare(project_dir, platform, plugins_dir);
-            // axe the directory
-            shell.rm('-rf', plugin_dir);
-            require('../plugman').emit('log', plugin_id + ' uninstalled.');
             if (callback) callback();
         }
     });