cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject git commit: [CB-4877]: Add --silent flag and basic logging.
Date Wed, 25 Sep 2013 15:54:25 GMT
Updated Branches:
  refs/heads/master 13c4fcd15 -> d873608f3


[CB-4877]: Add --silent flag and basic logging.


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

Branch: refs/heads/master
Commit: d873608f3a0ca869d2de12f28f7dcf7d6e4c8e1a
Parents: 13c4fcd
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Wed Sep 25 11:12:47 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Wed Sep 25 11:53:53 2013 -0400

----------------------------------------------------------------------
 main.js                  |  9 +++++++--
 spec/uninstall.spec.js   |  2 +-
 src/fetch.js             |  8 ++++----
 src/install.js           | 16 ++++++++--------
 src/prepare.js           | 10 +++++-----
 src/uninstall.js         | 23 ++++++++++++-----------
 src/util/action-stack.js | 18 +++++++++---------
 src/util/plugins.js      |  8 ++++----
 src/util/w8jsproj.js     |  2 +-
 9 files changed, 51 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index da62faa..3c18964 100755
--- a/main.js
+++ b/main.js
@@ -33,6 +33,7 @@ var known_opts = { 'platform' : [ 'ios', 'android', 'blackberry10', 'wp7',
'wp8'
         , 'version' : Boolean
         , 'help' : Boolean
         , 'debug' : Boolean
+        , 'silent' : Boolean
         , 'plugins': path
         , 'link': Boolean
         , 'variable' : Array
@@ -61,12 +62,16 @@ process.on('uncaughtException', function(error) {
 
 // Set up appropriate logging based on events
 if (cli_opts.debug) {
+    plugman.on('verbose', console.log);
+}
+
+if (!cli_opts.silent) {
     plugman.on('log', console.log);
+    plugman.on('warn', console.warn);
+    plugman.on('results', console.log);
 }
 
-plugman.on('warn', console.warn);
 plugman.on('error', console.error);
-plugman.on('results', console.log);
 
 if (cli_opts.version) {
     console.log(package.name + ' version ' + package.version);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/spec/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/spec/uninstall.spec.js b/spec/uninstall.spec.js
index 318caca..9d9add4 100644
--- a/spec/uninstall.spec.js
+++ b/spec/uninstall.spec.js
@@ -120,7 +120,7 @@ describe('uninstallPlatform', function() {
                 });
                 waitsFor(function() { return done; }, 'promise never resolved', 500);
                 runs(function() {
-                    expect(emit).toHaveBeenCalledWith('log', 'Uninstalling 2 dangling dependent
plugins...');
+                    expect(emit).toHaveBeenCalledWith('log', 'Uninstalling 2 dangling dependent
plugins.');
                 });
             });
             it('should not uninstall any dependencies that are relied on by other plugins');

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index f1052ac..727ff84 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -11,7 +11,7 @@ var shell   = require('shelljs'),
 // possible options: link, subdir, git_ref
 // Returns a promise.
 module.exports = function fetchPlugin(plugin_dir, plugins_dir, options) {
-    require('../plugman').emit('log', 'Fetching plugin from location "' + plugin_dir + '"...');
+    require('../plugman').emit('log', 'Fetching plugin from "' + plugin_dir + '"...');
     // Ensure the containing directory exists.
     shell.mkdir('-p', plugins_dir);
 
@@ -67,7 +67,7 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, options)
{
         var linkable = true;
         var movePlugin = function(plugin_dir) {
             var plugin_xml_path = path.join(plugin_dir, 'plugin.xml');
-            require('../plugman').emit('log', 'Fetch is reading plugin.xml from location
"' + plugin_xml_path + '"...');
+            require('../plugman').emit('verbose', 'Fetch is reading plugin.xml from location
"' + plugin_xml_path + '"...');
             var xml = xml_helpers.parseElementtreeSync(plugin_xml_path);
             var plugin_id = xml.getroot().attrib.id;
 
@@ -75,11 +75,11 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, options)
{
 
             shell.rm('-rf', dest);
             if (options.link && linkable) {
-                require('../plugman').emit('log', 'Symlinking from location "' + plugin_dir
+ '" to location "' + dest + '"');
+                require('../plugman').emit('verbose', 'Symlinking from location "' + plugin_dir
+ '" to location "' + dest + '"');
                 fs.symlinkSync(plugin_dir, dest, 'dir');
             } else {
                 shell.mkdir('-p', dest);
-                require('../plugman').emit('log', 'Copying from location "' + plugin_dir
+ '" to location "' + dest + '"');
+                require('../plugman').emit('verbose', 'Copying from location "' + plugin_dir
+ '" to location "' + dest + '"');
                 shell.cp('-R', path.join(plugin_dir, '*') , dest);
             }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index c541b74..bdb6662 100644
--- a/src/install.js
+++ b/src/install.js
@@ -89,7 +89,7 @@ function cleanVersionOutput(version, name){
         }else{
             out = out.substr(0, dev_index-1);
         }
-        require('../plugman').emit('log', name+' has been detected as using a development
branch. Attemping to install anyways.');
+        require('../plugman').emit('verbose', name+' has been detected as using a development
branch. Attemping to install anyways.');
     }     
     return out;
 }
@@ -119,7 +119,7 @@ function callEngineScripts(engines) {
             }else if(engine.currentVersion){
                 return cleanVersionOutput(engine.currentVersion, engine.name)
             }else{
-                require('../plugman').emit('log', 'Cordova project '+ engine.scriptSrc +'
not detected (lacks a '+ engine.scriptSrc +' script), continuing.');
+                require('../plugman').emit('verbose', 'Cordova project '+ engine.scriptSrc
+' not detected (lacks a '+ engine.scriptSrc +' script), continuing.');
                 return null;
             }
         })
@@ -175,7 +175,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions,
platfo
       , filtered_variables = {};
     var name         = plugin_et.findall('name').text;
     var plugin_id    = plugin_et.getroot().attrib['id'];
-    require('../plugman').emit('log', 'Starting installation of "' + plugin_id + '"...');
+    require('../plugman').emit('log', 'Starting installation of "' + plugin_id + '" for '
+ platform);
 
     // check if platform has plugin installed already.
     var platform_config = config_changes.get_platform_json(plugins_dir, platform);
@@ -220,7 +220,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions,
platfo
         var dependencies = plugin_et.findall('dependency') || [];
         dependencies = dependencies.concat(plugin_et.findall('./platform[@name="'+platform+'"]/dependency'));
         if (dependencies && dependencies.length) {
-            require('../plugman').emit('log', 'Dependencies detected, iterating through them...');
+            require('../plugman').emit('verbose', 'Dependencies detected, iterating through
them...');
             return Q.all(dependencies.map(function(dep) {
                 var dep_plugin_id = dep.attrib.id;
                 var dep_subdir = dep.attrib.subdir;
@@ -275,7 +275,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions,
platfo
                 return urlPromise.then(function(dep_url) {
                     var dep_plugin_dir = path.join(plugins_dir, dep_plugin_id);
                     if (fs.existsSync(dep_plugin_dir)) {
-                        require('../plugman').emit('log', 'Dependent plugin "' + dep_plugin_id
+ '" already fetched, using that version.');
+                        require('../plugman').emit('verbose', 'Dependent plugin "' + dep_plugin_id
+ '" already fetched, using that version.');
                         var opts = {
                             cli_variables: filtered_variables,
                             www_dir: options.www_dir,
@@ -283,7 +283,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions,
platfo
                         };
                         return runInstall(actions, platform, project_dir, dep_plugin_dir,
plugins_dir, opts);
                     } else {
-                        require('../plugman').emit('log', 'Dependent plugin "' + dep_plugin_id
+ '" not fetched, retrieving then installing.');
+                        require('../plugman').emit('verbose', 'Dependent plugin "' + dep_plugin_id
+ '" not fetched, retrieving then installing.');
                         var opts = {
                             cli_variables: filtered_variables,
                             www_dir: options.www_dir,
@@ -311,7 +311,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions,
platfo
 }
 
 function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir,
plugin_basename, plugin_dir, filtered_variables, www_dir, is_top_level) {
-    require('../plugman').emit('log', 'Installing plugin ' + plugin_id + '...');
+    require('../plugman').emit('verbose', 'Installing plugin ' + plugin_id);
     var handler = platform_modules[platform];
     www_dir = www_dir || handler.www_dir(project_dir);
 
@@ -356,7 +356,7 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir,
plu
         // call prepare after a successful install
         require('./../plugman').prepare(project_dir, platform, plugins_dir);
 
-        require('../plugman').emit('results', plugin_id + ' installed.');
+        require('../plugman').emit('log', plugin_id + ' installed on ' + platform + '.');
         // WIN!
         // Log out plugin INFO element contents in case additional install steps are necessary
         var info = plugin_et.findall('./info');

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 587c851..967af93 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -44,7 +44,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir)
{
     // - For each js-module (general first, then platform) build up an object storing the
path and any clobbers, merges and runs for it.
     // - Write this object into www/cordova_plugins.json.
     // - Cordova.js contains code to load them at runtime from that file.
-    require('../plugman').emit('log', 'Preparing ' + platform + ' project...');
+    require('../plugman').emit('log', 'Preparing ' + platform + ' project');
     var platform_json = config_changes.get_platform_json(plugins_dir, platform);
     var wwwDir = platform_modules[platform].www_dir(project_dir);
 
@@ -58,14 +58,14 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir)
{
                 var id = plug.id;
                 var plugin_modules = path.join(plugins_www, id);
                 if (fs.existsSync(plugin_modules)) {
-                    require('../plugman').emit('log', 'Removing plugins directory from www
"'+plugin_modules+'"');
+                    require('../plugman').emit('verbose', 'Removing plugins directory from
www "'+plugin_modules+'"');
                     shell.rm('-rf', plugin_modules);
                 }
             });
         }
     }
 
-    require('../plugman').emit('log', 'Processing configuration changes for plugins.');
+    require('../plugman').emit('verbose', 'Processing configuration changes for plugins.');
     config_changes.process(plugins_dir, project_dir, platform);
 
     // for windows phone plaform we need to add all www resources to the .csproj file
@@ -117,7 +117,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir)
{
     // This array holds all the metadata for each module and ends up in cordova_plugins.json
     var plugins = Object.keys(platform_json.installed_plugins).concat(Object.keys(platform_json.dependent_plugins));
     var moduleObjects = [];
-    require('../plugman').emit('log', 'Iterating over installed plugins:', plugins);
+    require('../plugman').emit('verbose', 'Iterating over installed plugins:', plugins);
 
     plugins && plugins.forEach(function(plugin) {
         var pluginDir = path.join(plugins_dir, plugin);
@@ -197,7 +197,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir)
{
     // Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js
     var final_contents = "cordova.define('cordova/plugin_list', function(require, exports,
module) {\n";
     final_contents += 'module.exports = ' + JSON.stringify(moduleObjects,null,'    ') + '\n});';
-    require('../plugman').emit('log', 'Writing out cordova_plugins.js...');
+    require('../plugman').emit('verbose', 'Writing out cordova_plugins.js...');
     fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), final_contents, 'utf-8');
 
     if(platform == 'wp7' || platform == 'wp8' || platform == "windows8") {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index 1dbfa73..335c3ac 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -48,23 +48,24 @@ module.exports.uninstallPlugin = function(id, plugins_dir) {
     var xml_path     = path.join(plugin_dir, 'plugin.xml')
       , plugin_et    = xml_helpers.parseElementtreeSync(xml_path);
 
-    require('../plugman').emit('log', 'Removing plugin ' + id + '...');
+    require('../plugman').emit('log', 'Deleting plugin ' + id);
     // Check for dependents
     var dependencies = plugin_et.findall('dependency');
     if (dependencies && dependencies.length) {
-        require('../plugman').emit('log', 'Dependencies detected, iterating through them
and removing them first...');
-        return Q.all(
-            dependencies.map(function(dep) {
+        require('../plugman').emit('verbose', 'Dependencies detected, iterating through them
and removing them first.');
+        return dependencies.reduce(function(soFar, dep) {
+            return soFar.then(function() {
                 return module.exports.uninstallPlugin(dep.attrib.id, plugins_dir);
-            })
-        ).then(function() {
+            });
+        }, Q())
+        .then(function() {
             shell.rm('-rf', plugin_dir);
-            require('../plugman').emit('log', id + ' removed.');
+            require('../plugman').emit('verbose', id + ' deleted.');
         });
     } else {
         // axe the directory
         shell.rm('-rf', plugin_dir);
-        require('../plugman').emit('results', 'Deleted "' + plugin_dir + '".');
+        require('../plugman').emit('verbose', 'Deleted "' + plugin_dir + '".');
         return Q();
     }
 };
@@ -97,7 +98,7 @@ function runUninstall(actions, platform, project_dir, plugin_dir, plugins_dir,
o
     diff_arr.unshift(dependents);
     var danglers = underscore.difference.apply(null, diff_arr);
     if (dependents.length && danglers && danglers.length) {
-        require('../plugman').emit('log', 'Uninstalling ' + danglers.length + ' dangling
dependent plugins...');
+        require('../plugman').emit('log', 'Uninstalling ' + danglers.length + ' dangling
dependent plugins.');
         return Q.all(
             danglers.map(function(dangler) {
                 var dependent_path = path.join(plugins_dir, dangler);
@@ -123,7 +124,7 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir,
w
     var handler = platform_modules[platform];
     var platformTag = plugin_et.find('./platform[@name="'+platform+'"]');
     www_dir = www_dir || handler.www_dir(project_dir);
-    require('../plugman').emit('log', 'Uninstalling ' + plugin_id + '...');
+    require('../plugman').emit('log', 'Uninstalling ' + plugin_id + ' from ' + platform);
 
     var assets = plugin_et.findall('./asset');
     if (platformTag) {
@@ -161,7 +162,7 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir,
w
     return actions.process(platform, project_dir)
     .then(function() {
         // WIN!
-        require('../plugman').emit('results', plugin_id + ' uninstalled.');
+        require('../plugman').emit('verbose', plugin_id + ' uninstalled from ' + platform
+ '.');
         // queue up the plugin so prepare can remove the config changes
         config_changes.add_uninstalled_plugin_to_prepare_queue(plugins_dir, path.basename(plugin_dir),
platform, is_top_level);
         // call prepare after a successful uninstall

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/util/action-stack.js
----------------------------------------------------------------------
diff --git a/src/util/action-stack.js b/src/util/action-stack.js
index 920dfea..122e19b 100644
--- a/src/util/action-stack.js
+++ b/src/util/action-stack.js
@@ -28,25 +28,25 @@ ActionStack.prototype = {
     },
     // Returns a promise.
     process:function(platform, project_dir) {
-        require('../../plugman').emit('log', 'Beginning processing of action stack for '
+ platform + ' project...');
+        require('../../plugman').emit('verbose', 'Beginning processing of action stack for
' + platform + ' project...');
         var project_files;
         // parse platform-specific project files once
-        require('../../plugman').emit('log', 'Parsing ' + platform + ' project files...');
+        require('../../plugman').emit('verbose', 'Parsing ' + platform + ' project files...');
         switch(platform) {
             case "ios": 
-                require('../../plugman').emit('log', 'Parsing iOS project files...');
+                require('../../plugman').emit('verbose', 'Parsing iOS project files...');
                 project_files = ios.parseIOSProjectFiles(project_dir);
                 break;
             case "wp7": 
-                require('../../plugman').emit('log', 'Parsing WP7 project files...');
+                require('../../plugman').emit('verbose', 'Parsing WP7 project files...');
                 project_files = wp7.parseProjectFile(project_dir);
                 break;
             case "wp8": 
-                require('../../plugman').emit('log', 'Parsing WP8 project files...');
+                require('../../plugman').emit('verbose', 'Parsing WP8 project files...');
                 project_files = wp8.parseProjectFile(project_dir);
                 break;
             case "windows8": 
-                require('../../plugman').emit('log', 'Parsing Windows8 project files...');
+                require('../../plugman').emit('verbose', 'Parsing Windows8 project files...');
                 project_files = windows8.parseProjectFile(project_dir);
                 break;
         }
@@ -87,14 +87,14 @@ ActionStack.prototype = {
             }
             this.completed.push(action);
         }
-        require('../../plugman').emit('log', 'Action stack processing complete.');
+        require('../../plugman').emit('verbose', 'Action stack processing complete.');
         if (platform == 'ios') {
             // write out xcodeproj file
-            require('../../plugman').emit('log', 'Writing out iOS pbxproj file...');
+            require('../../plugman').emit('verbose', 'Writing out iOS pbxproj file...');
             fs.writeFileSync(project_files.pbx, project_files.xcode.writeSync());
         }
         if (platform == 'wp7' || platform == 'wp8' || platform == "windows8") {
-            require('../../plugman').emit('log', 'Writing out ' + platform + ' project files...');
+            require('../../plugman').emit('verbose', 'Writing out ' + platform + ' project
files...');
             project_files.write();
         }
         return Q();

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 2bf78e2..170d7b0 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -42,7 +42,7 @@ module.exports = {
 
         shell.cd(path.dirname(tmp_dir));
         var cmd = util.format('git clone "%s" "%s"', plugin_git_url, path.basename(tmp_dir));
-        require('../../plugman').emit('log', 'Fetching plugin via git-clone command: ' +
cmd);
+        require('../../plugman').emit('verbose', 'Fetching plugin via git-clone command:
' + cmd);
         var d = Q.defer();
         child_process.exec(cmd, function(err, stdout, stderr) {
             if (err) {
@@ -52,7 +52,7 @@ module.exports = {
             }
         });
         return d.promise.then(function() {
-            require('../../plugman').emit('log', 'Plugin "' + plugin_git_url + '" fetched.');
+            require('../../plugman').emit('verbose', 'Plugin "' + plugin_git_url + '" fetched.');
             // Check out the specified revision, if provided.
             if (git_ref) {
                 var cmd = util.format('git checkout "%s"', tmp_dir, git_ref);
@@ -76,10 +76,10 @@ 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.
             var plugin_dir = path.join(plugins_dir, plugin_id);
-            require('../../plugman').emit('log', 'Copying fetched plugin over "' + plugin_dir
+ '"...');
+            require('../../plugman').emit('verbose', 'Copying fetched plugin over "' + plugin_dir
+ '"...');
             shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
 
-            require('../../plugman').emit('log', 'Plugin "' + plugin_id + '" fetched.');
+            require('../../plugman').emit('verbose', 'Plugin "' + plugin_id + '" fetched.');
             return plugin_dir;
         });
     }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d873608f/src/util/w8jsproj.js
----------------------------------------------------------------------
diff --git a/src/util/w8jsproj.js b/src/util/w8jsproj.js
index e589b81..bd5dd41 100644
--- a/src/util/w8jsproj.js
+++ b/src/util/w8jsproj.js
@@ -8,7 +8,7 @@ var xml_helpers = require('./xml-helpers'),
     fs = require('fs');
 
 function jsproj(location) {
-    require('../../plugman').emit('log','creating jsproj from project at : ' + location);
+    require('../../plugman').emit('verbose','creating jsproj from project at : ' + location);
     this.location = location;
     this.xml = xml_helpers.parseElementtreeSync(location);
     return this;


Mime
View raw message