You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/10/07 07:28:04 UTC

[1/3] cordova-lib git commit: CB-9589 added more warnings and added conversion step to fetch.js

Repository: cordova-lib
Updated Branches:
  refs/heads/master ff0fd6e2e -> 3e3d4c60b


CB-9589 added more warnings and added conversion step to fetch.js


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

Branch: refs/heads/master
Commit: 3e3d4c60be21f893c52ca4ebb895119befcbb658
Parents: 1c0810a
Author: Steve Gill <st...@gmail.com>
Authored: Mon Oct 5 17:17:20 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 6 17:40:12 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/plugman/fetch.js     | 7 ++++++-
 cordova-lib/src/plugman/install.js   | 4 ++--
 cordova-lib/src/plugman/uninstall.js | 2 ++
 3 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3e3d4c60/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 33e36ed..9fe0b24 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -132,6 +132,11 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
                 ));
             }
             // If not found in local search path, fetch from the registry.
+            var newID = pluginMapperotn[plugin_src];
+            if(newID) {
+                events.emit('warn', 'Notice: ' + plugin_src + ' has been automatically converted to ' + newID + ' and fetched from npm. This is due to our old plugins registry shutting down.');                
+                plugin_src = newID;
+            } 
             return registry.fetch([plugin_src], options.client)
             .fail(function (error) {
                 var message = 'Failed to fetch plugin ' + plugin_src + ' via registry.' +
@@ -142,7 +147,7 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
             })
             .then(function(dir) {
                 return {
-                    pinfo: pluginInfoProvider.get(dir),
+                        pinfo: pluginInfoProvider.get(dir),
                     fetchJsonSource: {
                         type: 'registry',
                         id: plugin_src

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3e3d4c60/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index c8d7e64..ec1fc76 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -86,7 +86,7 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
     //if it does, convert id to new name id 
     var newId = pluginMapper[splitVersion[0]];
     if(newId) {
-        events.emit('log', 'Notice: ' + id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
+        events.emit('warn', 'Notice: ' + id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
         if(splitVersion[1]) {
             id = newId +'@'+splitVersion[1];
         } else {
@@ -424,7 +424,7 @@ function installDependencies(install, dependencies, options) {
                 //if it does, convert id to new name id 
                 var newId = pluginMapper[splitVersion[0]];
                 if(newId) {
-                    events.emit('log', 'Notice: ' + dep.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
+                    events.emit('warn', 'Notice: ' + dep.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
                     if(splitVersion[1]) {
                         dep.id = newId +'@'+splitVersion[1];
                     } else {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3e3d4c60/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 7251d35..e4565fe 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -150,6 +150,7 @@ module.exports.uninstallPlugin = function(id, plugins_dir, options) {
             if (!fs.existsSync(deps_path)) {
                 var newId = pluginMapper[splitVersion[0]];
                 if (newId && toDelete.indexOf(newId) === -1) {
+                   events.emit('verbose', 'Automatically converted ' + d.id + ' to ' + newId + 'for uninstallation.');
                    toDelete.push(newId);
                    findDependencies(newId);
                 }
@@ -272,6 +273,7 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir, plugin
                 var newId = pluginMapper[splitVersion[0]];
                 if(newId) {
                     dependent_path = path.join(plugins_dir, newId);
+                    events.emit('verbose', 'Automatically converted ' + dangler + ' to ' + newId + 'for uninstallation.');
                 }
             }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[3/3] cordova-lib git commit: CB-9589 auto convert old plugin ids to new npm ids

Posted by st...@apache.org.
CB-9589 auto convert old plugin ids to new npm ids


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

Branch: refs/heads/master
Commit: a7287ce39d310c89d458ba4d4491dddeaeb23e92
Parents: ff0fd6e
Author: Steve Gill <st...@gmail.com>
Authored: Fri Sep 25 12:21:09 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 6 17:40:12 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/plugman/fetch.js             |  2 +-
 cordova-lib/src/plugman/install.js           | 35 ++++++++++++++++++++---
 cordova-lib/src/plugman/registry/registry.js | 19 +-----------
 cordova-lib/src/plugman/uninstall.js         | 29 +++++++++++++++----
 4 files changed, 57 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a7287ce3/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index ad463d7..ad511e4 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -167,7 +167,6 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
     });
 }
 
-
 // Helper function for checking expected plugin IDs against reality.
 function checkID(expectedIdAndVersion, pinfo) {
     if (!expectedIdAndVersion) return;
@@ -181,6 +180,7 @@ function checkID(expectedIdAndVersion, pinfo) {
     }
 }
 
+
 // Note, there is no cache invalidation logic for local plugins.
 // As of this writing loadLocalPlugins() is never called with different
 // search paths and such case would not be handled properly.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a7287ce3/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index 67198e5..c8d7e64 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -36,6 +36,7 @@ var path = require('path'),
     plugman = require('./plugman'),
     HooksRunner = require('../hooks/HooksRunner'),
     isWindows = (os.platform().substr(0,3) === 'win'),
+    pluginMapper = require('cordova-registry-mapper').oldToNew,
     cordovaUtil = require('../cordova/util');
 
 var superspawn = require('cordova-common').superspawn;
@@ -48,7 +49,8 @@ var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
    providing a high-level logic flow overview.
    1. module.exports (installPlugin)
      a) checks that the platform is supported
-     b) invokes possiblyFetch
+     b) converts oldIds into newIds (CPR -> npm)
+     c) invokes possiblyFetch
    2. possiblyFetch
      a) checks that the plugin is fetched. if so, calls runInstall
      b) if not, invokes plugman.fetch, and when done, calls runInstall
@@ -56,7 +58,7 @@ var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
      a) checks if the plugin is already installed. if so, calls back (done).
      b) if possible, will check the version of the project and make sure it is compatible with the plugin (checks <engine> tags)
      c) makes sure that any variables required by the plugin are specified. if they are not specified, plugman will throw or callback with an error.
-     d) if dependencies are listed in the plugin, it will recurse for each dependent plugin and call possiblyFetch (2) on each one. When each dependent plugin is successfully installed, it will then proceed to call handleInstall (4)
+     d) if dependencies are listed in the plugin, it will recurse for each dependent plugin, autoconvert IDs to newIDs and call possiblyFetch (2) on each one. When each dependent plugin is successfully installed, it will then proceed to call handleInstall (4)
    4. handleInstall
      a) queues up actions into a queue (asset, source-file, headers, etc)
      b) processes the queue
@@ -68,7 +70,6 @@ var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
 module.exports = function installPlugin(platform, project_dir, id, plugins_dir, options) {
     project_dir = cordovaUtil.convertToRealPathSafe(project_dir);
     plugins_dir = cordovaUtil.convertToRealPathSafe(plugins_dir);
-
     options = options || {};
     options.is_top_level = true;
     plugins_dir = plugins_dir || path.join(project_dir, 'cordova', 'plugins');
@@ -79,6 +80,19 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
 
     var current_stack = new action_stack();
 
+    // Split @Version from the plugin id if it exists.
+    var splitVersion = id.split('@');
+    //Check if a mapping exists for the plugin id
+    //if it does, convert id to new name id 
+    var newId = pluginMapper[splitVersion[0]];
+    if(newId) {
+        events.emit('log', 'Notice: ' + id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
+        if(splitVersion[1]) {
+            id = newId +'@'+splitVersion[1];
+        } else {
+            id = newId;
+        }
+     }     
     return possiblyFetch(id, plugins_dir, options)
     .then(function(plugin_dir) {
         return runInstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options);
@@ -404,6 +418,20 @@ function installDependencies(install, dependencies, options) {
     return dependencies.reduce(function(soFar, dep) {
         return soFar.then(
             function() {
+                // Split @Version from the plugin id if it exists.
+                var splitVersion = dep.id.split('@');
+                //Check if a mapping exists for the plugin id
+                //if it does, convert id to new name id 
+                var newId = pluginMapper[splitVersion[0]];
+                if(newId) {
+                    events.emit('log', 'Notice: ' + dep.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
+                    if(splitVersion[1]) {
+                        dep.id = newId +'@'+splitVersion[1];
+                    } else {
+                        dep.id = newId;
+                    }
+                }
+
                 dep.git_ref = dep.commit;
 
                 if (dep.subdir) {
@@ -528,7 +556,6 @@ function installDependency(dep, install, options) {
     var opts;
 
     dep.install_dir = path.join(install.plugins_dir, dep.id);
-
     if ( fs.existsSync(dep.install_dir) ) {
         events.emit('verbose', 'Dependent plugin "' + dep.id + '" already fetched, using that version.');
         opts = underscore.extend({}, options, {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a7287ce3/cordova-lib/src/plugman/registry/registry.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/registry/registry.js b/cordova-lib/src/plugman/registry/registry.js
index cc39f40..5624c4e 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -26,7 +26,6 @@ var npm = require('npm'),
     rc = require('rc'),
     Q = require('q'),
     request = require('request'),
-    pluginMapper = require('cordova-registry-mapper').oldToNew,
     npmhelper = require('../../util/npm-helper'),
     home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
     events = require('cordova-common').events,
@@ -292,22 +291,6 @@ function isValidCprName(plugin) {
     //If matches equals null, plugin is not reverse domain name style
     if(matches === null) {
         return false;
-    } else {
-        warnIfIdInMapper(splitVersion[0]);
-    }
+    } 
     return true;
 }
-
-/**
- * @param plugin:{Array} - the plugin id or "id@version"
- * @param matches:{Array} - the array containing the RDN style plugin id without @version
- */
-function warnIfIdInMapper(plugin) {
-    //Reverse domain name style plugin ID
-    //Check if a mapping exists for the plugin id
-    //if it does, warn the users to use package-name
-    var packageName = pluginMapper[plugin];
-    if(packageName) {
-        events.emit('log', 'WARNING: ' + plugin + ' has been renamed to ' + packageName + '. You may not be getting the latest version! We suggest you `cordova plugin rm ' + plugin + '` and `cordova plugin add ' + packageName + '`.');
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a7287ce3/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 545a336..3771c1b 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -32,7 +32,8 @@ var path = require('path'),
     platform_modules = require('../platforms/platforms'),
     promiseutil = require('../util/promise-util'),
     HooksRunner = require('../hooks/HooksRunner'),
-    cordovaUtil      = require('../cordova/util');
+    cordovaUtil = require('../cordova/util'),
+    pluginMapper = require('cordova-registry-mapper').oldToNew;
 
 var superspawn = require('cordova-common').superspawn;
 var PlatformJson = require('cordova-common').PlatformJson;
@@ -142,10 +143,19 @@ module.exports.uninstallPlugin = function(id, plugins_dir, options) {
         var pluginInfo = pluginInfoProvider.get(depPluginDir);
         // TODO: Should remove dependencies in a separate step, since dependencies depend on platform.
         var deps = pluginInfo.getDependencies();
+        var deps_path;
         deps.forEach(function (d) {
-            if (toDelete.indexOf(d.id) === -1) {
-                toDelete.push(d.id);
-                findDependencies(d.id);
+            var splitVersion = d.id.split('@');
+            deps_path = path.join(plugin_dir, '..', splitVersion[0]);
+            if (!fs.existsSync(deps_path)) {
+                    var newId = pluginMapper[splitVersion[0]];
+                    if (newId && toDelete.indexOf(newId) === -1) {
+                        toDelete.push(newId);
+                        findDependencies(newId);
+                    }
+            } else if (toDelete.indexOf(d.id) === -1) {
+                    toDelete.push(d.id);
+                    findDependencies(d.id);
             }
         });
     }
@@ -256,9 +266,18 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir, plugin
         promise = promiseutil.Q_chainmap(danglers, function(dangler) {
             var dependent_path = path.join(plugins_dir, dangler);
 
+            //try to convert ID if old-id path doesn't exist. 
+            if (!fs.existsSync(dependent_path)) {
+                var splitVersion = dangler.split('@');
+                var newId = pluginMapper[splitVersion[0]];
+                if(newId) {
+                    dependent_path = path.join(plugins_dir, newId);
+                }
+            }
+
             var opts = underscore.extend({}, options, {
                 is_top_level: depsInfo.top_level_plugins.indexOf(dangler) > -1,
-                depsInfo: depsInfo
+                depsInfo: depsInfo  
             });
 
             return runUninstallPlatform(actions, platform, project_dir, dependent_path, plugins_dir, opts);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/3] cordova-lib git commit: CB-9589 added test to check id conversion

Posted by st...@apache.org.
CB-9589 added test to check id conversion


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

Branch: refs/heads/master
Commit: 1c0810a86d6a946d75220271125d455759fb90e7
Parents: a7287ce
Author: Steve Gill <st...@gmail.com>
Authored: Fri Oct 2 19:08:16 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 6 17:40:12 2015 -0700

----------------------------------------------------------------------
 cordova-lib/spec-plugman/install.spec.js | 14 ++++++++++++++
 cordova-lib/src/plugman/fetch.js         |  1 -
 cordova-lib/src/plugman/uninstall.js     | 16 ++++++++--------
 3 files changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1c0810a8/cordova-lib/spec-plugman/install.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/install.spec.js b/cordova-lib/spec-plugman/install.spec.js
index e8a3cd5..572ffde 100644
--- a/cordova-lib/spec-plugman/install.spec.js
+++ b/cordova-lib/spec-plugman/install.spec.js
@@ -227,6 +227,20 @@ describe('install', function() {
                 expect(fetchSpy).toHaveBeenCalled();
             });
         });
+        it('should call fetch and convert oldID to newID', function() {
+            fetchSpy.andReturn( Q( plugins['org.test.plugins.dummyplugin'] ) );
+            spyOn(fs, 'existsSync').andCallFake( fake['existsSync']['noPlugins'] );
+            var emit = spyOn(events, 'emit');
+            runs(function() {
+                installPromise(install('android', project, 'org.apache.cordova.device' ));
+            });
+            waitsFor(function() { return done; }, 'install promise never resolved', 200);
+            runs(function() {
+                expect(emit.calls[0].args[1]).toBe('Notice: org.apache.cordova.device has been automatically converted to cordova-plugin-device and fetched from npm. This is due to our old plugins registry shutting down.');
+                expect(done).toBe(true);
+                expect(fetchSpy).toHaveBeenCalled();
+            });
+        });
 
         describe('engine versions', function () {
             var fail, satisfies;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1c0810a8/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index ad511e4..33e36ed 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -180,7 +180,6 @@ function checkID(expectedIdAndVersion, pinfo) {
     }
 }
 
-
 // Note, there is no cache invalidation logic for local plugins.
 // As of this writing loadLocalPlugins() is never called with different
 // search paths and such case would not be handled properly.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1c0810a8/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 3771c1b..7251d35 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -148,14 +148,14 @@ module.exports.uninstallPlugin = function(id, plugins_dir, options) {
             var splitVersion = d.id.split('@');
             deps_path = path.join(plugin_dir, '..', splitVersion[0]);
             if (!fs.existsSync(deps_path)) {
-                    var newId = pluginMapper[splitVersion[0]];
-                    if (newId && toDelete.indexOf(newId) === -1) {
-                        toDelete.push(newId);
-                        findDependencies(newId);
-                    }
+                var newId = pluginMapper[splitVersion[0]];
+                if (newId && toDelete.indexOf(newId) === -1) {
+                   toDelete.push(newId);
+                   findDependencies(newId);
+                }
             } else if (toDelete.indexOf(d.id) === -1) {
-                    toDelete.push(d.id);
-                    findDependencies(d.id);
+                toDelete.push(d.id);
+                findDependencies(d.id);
             }
         });
     }
@@ -277,7 +277,7 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir, plugin
 
             var opts = underscore.extend({}, options, {
                 is_top_level: depsInfo.top_level_plugins.indexOf(dangler) > -1,
-                depsInfo: depsInfo  
+                depsInfo: depsInfo
             });
 
             return runUninstallPlatform(actions, platform, project_dir, dependent_path, plugins_dir, opts);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org