Updated Branches: refs/heads/master b857a49a7 -> 009e8c708
adding search and fetch Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/f5158ecb Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/f5158ecb Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/f5158ecb Branch: refs/heads/master Commit: f5158ecbfe26917973df1b906b6754b201742c3a Parents: 062849f Author: Anis Kadri <[email protected]> Authored: Mon Jul 15 17:34:17 2013 -0700 Committer: Anis Kadri <[email protected]> Committed: Mon Jul 15 17:34:17 2013 -0700 ---------------------------------------------------------------------- package.json | 2 +- spec/plugin.spec.js | 13 ++++++++++--- src/plugin.js | 26 +++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5158ecb/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 9b8ca88..103ef96 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "colors":">=0.6.0", "elementtree":"0.1.3", - "plugman":"0.8.2", + "plugman":"git://github.com/apache/cordova-plugman.git#plugman-registry", "plist":"0.4.x", "xcode":"0.5.1", "express":"3.0.0", http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5158ecb/spec/plugin.spec.js ---------------------------------------------------------------------- diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js index f340151..bdebf53 100644 --- a/spec/plugin.spec.js +++ b/spec/plugin.spec.js @@ -33,7 +33,7 @@ var project_dir = path.join('some','path'); var plugins_dir = path.join(project_dir, 'plugins'); describe('plugin command', function() { - var is_cordova, list_platforms, fire, find_plugins, rm, mkdir, existsSync, exec, prep_spy, plugman_install, plugman_fetch, parsers = {}, uninstall; + var is_cordova, list_platforms, fire, find_plugins, rm, mkdir, existsSync, exec, prep_spy, plugman_install, plugman_fetch, parsers = {}, plugman_uninstall; beforeEach(function() { is_cordova = spyOn(util, 'isCordova').andReturn(project_dir); fire = spyOn(hooker.prototype, 'fire').andCallFake(function(e, opts, cb) { @@ -61,7 +61,8 @@ describe('plugin command', function() { }); plugman_install = spyOn(plugman, 'install'); plugman_fetch = spyOn(plugman, 'fetch').andCallFake(function(target, plugins_dir, opts, cb) { cb(false, path.join(plugins_dir, target)); }); - uninstall = spyOn(plugman, 'uninstall'); + plugman_uninstall = spyOn(plugman, 'uninstall'); + plugman_search = spyOn(plugman, 'search'); }); describe('failure', function() { @@ -127,6 +128,12 @@ describe('plugin command', function() { }); }); }); + describe('`search`', function() { + it('should call plugman.search', function() { + cordova.plugin('search', sample_plugins); + expect(plugman_search).toHaveBeenCalledWith(sample_plugins, jasmine.any(Function)); + }); + }); describe('`remove`',function() { var plugin_parser; var subset = ['android', 'wp7']; @@ -145,7 +152,7 @@ describe('plugin command', function() { cordova.plugin('rm', sample_plugins); sample_plugins.forEach(function(plug) { subset.forEach(function(plat) { - expect(uninstall).toHaveBeenCalledWith(plat, path.join(project_dir, 'platforms', plat), plug, plugins_dir, jasmine.any(Object)); + expect(plugman_uninstall).toHaveBeenCalledWith(plat, path.join(project_dir, 'platforms', plat), plug, plugins_dir, jasmine.any(Object)); }); }); }); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5158ecb/src/plugin.js ---------------------------------------------------------------------- diff --git a/src/plugin.js b/src/plugin.js index ca43e35..4926964 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -62,7 +62,7 @@ module.exports = function plugin(command, targets, callback) { }; switch(command) { - case 'add': + case 'add': var end = n(targets.length, function() { hooks.fire('after_plugin_add', opts, function(err) { if (err) { @@ -159,6 +159,30 @@ module.exports = function plugin(command, targets, callback) { } }); break; + case 'search': + hooks.fire('before_plugin_search', function(err) { + if (err) { + if(callback) callback(err); + else throw err; + } else { + plugman.search(targets, function(err, plugins) { + if(err) return console.log(err); + for(var plugin in plugins) { + console.log(); + events.emit('results', plugins[plugin].name, '-', plugins[plugin].description || 'no description provided'); + } + hooks.fire('after_plugin_search', function(err) { + if(err) { + if(callback) callback(err); + else throw err; + } + }); + }); + + } + + }); + break; case 'ls': case 'list': default:
