cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [33/39] cordova-lib git commit: CB-12016 : removed pluginMapper code from uninstall
Date Sat, 15 Apr 2017 01:10:54 GMT
CB-12016 : removed pluginMapper code from uninstall

 This closes #522


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

Branch: refs/heads/common-2.0.x
Commit: 43d7eaf20aa07fae34c36ea5bf445a49c4241372
Parents: e62852c
Author: Audrey So <audreyso@apache.org>
Authored: Fri Feb 24 10:59:56 2017 -0800
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Fri Mar 24 16:58:46 2017 -0700

----------------------------------------------------------------------
 cordova-lib/package.json                 |  1 -
 cordova-lib/spec-plugman/fetch.spec.js   | 19 ++++-----
 cordova-lib/spec-plugman/install.spec.js | 21 +--------
 cordova-lib/src/cordova/plugin.js        | 16 +------
 cordova-lib/src/plugman/fetch.js         | 61 ++++++---------------------
 cordova-lib/src/plugman/install.js       | 24 +----------
 cordova-lib/src/plugman/uninstall.js     | 28 ++----------
 7 files changed, 28 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index a4054a6..41d2011 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -23,7 +23,6 @@
     "cordova-create": "^1.0.1",
     "cordova-fetch": "1.0.2",
     "cordova-js": "4.2.1",
-    "cordova-registry-mapper": "1.x",
     "cordova-serve": "^1.0.0",
     "dep-graph": "1.1.0",
     "elementtree": "0.1.6",

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/cordova-lib/spec-plugman/fetch.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/fetch.spec.js b/cordova-lib/spec-plugman/fetch.spec.js
index a37df67..f22832f 100644
--- a/cordova-lib/spec-plugman/fetch.spec.js
+++ b/cordova-lib/spec-plugman/fetch.spec.js
@@ -81,11 +81,12 @@ describe('fetch', function() {
                 expect(cp).toHaveBeenCalledWith('-R', path.join(test_plugin, '*'), path.join(temp,
test_plugin_id));
             });
         });
-        it('Tet 003 : should create a symlink if used with `link` param', function(done)
{
+        it('Test 003 : should create a symlink if used with `link` param', function(done)
{
             wrapper(fetch(test_plugin, temp, { link: true }), done, function() {
                 expect(sym).toHaveBeenCalledWith(test_plugin, path.join(temp, test_plugin_id),
'dir');
             });
         });
+
         it('Test 004 : should fail when the expected ID doesn\'t match', function(done) {
             fetch(test_plugin, temp, { expected_id: 'wrongID' })
             .then(function() {
@@ -94,6 +95,7 @@ describe('fetch', function() {
                 expect(''+err).toContain('Expected plugin to have ID "wrongID" but got');
             }).fin(done);
         });
+
         it('Test 005 : should succeed when the expected ID is correct', function(done) {
             wrapper(fetch(test_plugin, temp, { expected_id: test_plugin_id }), done, function()
{
                 expect(1).toBe(1);
@@ -190,6 +192,7 @@ describe('fetch', function() {
                 expect(''+err).toContain('Expected plugin to have ID "wrongID" but got');
             }).fin(done);
         });
+
         it('Test 015 : should fail when the expected ID with version specified doesn\'t match',
function(done) {
             fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id@wrongVersion'
})
             .then(function() {
@@ -198,6 +201,7 @@ describe('fetch', function() {
                 expect(''+err).toContain('Expected plugin to have ID "id" but got');
             }).fin(done);
         });
+
         it('Test 016 : should succeed when the expected ID is correct', function(done) {
             wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id:
test_plugin_id }), done, function() {
                 expect(1).toBe(1);
@@ -272,8 +276,8 @@ describe('fetch', function() {
             realrm('-rf', temp);
         });
 
-
-        it('Test 022 : should fail when the expected ID doesn\'t match', function(done) {
+        it('Test 022 : should fail when the expected ID with version specified doesn\'t match',
function(done) {
+            //fetch(pluginId, temp, { expected_id: test_plugin_id + '@wrongVersion' })
             fetch(pluginId, temp, { expected_id: 'wrongID' })
             .then(function() {
                 expect('this call').toBe('fail');
@@ -281,14 +285,7 @@ describe('fetch', function() {
                 expect(''+err).toContain('Expected plugin to have ID "wrongID" but got');
             }).fin(done);
         });
-        it('Test 022 : should fail when the expected ID with version specified doesn\'t match',
function(done) {
-            fetch(pluginId, temp, { expected_id: test_plugin_id + '@wrongVersion' })
-            .then(function() {
-                expect('this call').toBe('fail');
-            }, function(err) {
-                expect(''+err).toContain('to satisfy version "wrongVersion" but got');
-            }).fin(done);
-        });
+        
         it('Test 023 : should succeed when the expected ID is correct', function(done) {
             wrapper(fetch(pluginId, temp, { expected_id: test_plugin_id }), done, function()
{
                 expect(1).toBe(1);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/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 86977a3..713df96 100644
--- a/cordova-lib/spec-plugman/install.spec.js
+++ b/cordova-lib/spec-plugman/install.spec.js
@@ -227,25 +227,8 @@ describe('install', function() {
                 expect(fetchSpy).toHaveBeenCalled();
                 done();
             });
-        }, TIMEOUT);
-
-        it('Test 006 : should call fetch and convert oldID to newID', function(done) {
-            fetchSpy.and.returnValue( Q( plugins['org.test.plugins.dummyplugin'] ) );
-            spyOn(fs, 'existsSync').and.callFake( fake['existsSync']['noPlugins'] );
-            var emit = spyOn(events, 'emit');
-            install('android', project, 'org.apache.cordova.device' )
-            .then(function(res) {
-                return true;
-            })
-            .fail(function(err){
-                expect(err).toBeUndefined();
-            })
-            .fin(function () {
-                expect(emit.calls.argsFor(0)[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(fetchSpy).toHaveBeenCalled();
-                done();
-            });
-        }, TIMEOUT);
+        });
+        
         describe('engine versions', function () {
             var fail, satisfies;
             beforeEach(function () {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 121fc0f..0cfb3d7 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -27,7 +27,6 @@ var cordova_util  = require('./util'),
     shell         = require('shelljs'),
     PluginInfoProvider = require('cordova-common').PluginInfoProvider,
     plugman       = require('../plugman/plugman'),
-    pluginMapper  = require('cordova-registry-mapper').newToOld,
     pluginSpec    = require('./plugin_spec_parser'),
     events        = require('cordova-common').events,
     metadata      = require('../plugman/util/metadata'),
@@ -474,12 +473,6 @@ function validatePluginId(pluginId, installedPlugins) {
         return pluginId;
     }
 
-    var oldStylePluginId = pluginMapper[pluginId];
-    if (oldStylePluginId) {
-        events.emit('log', 'Plugin "' + pluginId + '" is not present in the project. Checking
for legacy id "' + oldStylePluginId + '".');
-        return installedPlugins.indexOf(oldStylePluginId) >= 0 ? oldStylePluginId : null;
-    }
-
     if (pluginId.indexOf('cordova-plugin-') < 0) {
         return validatePluginId('cordova-plugin-' + pluginId, installedPlugins);
     }
@@ -545,14 +538,7 @@ function getPluginVariables(variables){
 function getVersionFromConfigFile(plugin, cfg){
     var parsedSpec = pluginSpec.parse(plugin);
     var pluginEntry = cfg.getPlugin(parsedSpec.id);
-    if (!pluginEntry && !parsedSpec.scope) {
-        // If the provided plugin id is in the new format (e.g. cordova-plugin-camera), it
might be stored in config.xml
-        // under the old format (e.g. org.apache.cordova.camera), so check for that.
-        var oldStylePluginId = pluginMapper[parsedSpec.id];
-        if (oldStylePluginId) {
-            pluginEntry = cfg.getPlugin(oldStylePluginId);
-        }
-    }
+
     return pluginEntry && pluginEntry.spec;
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 6490ef3..0489583 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -30,8 +30,6 @@ var shell   = require('shelljs'),
     path    = require('path'),
     Q       = require('q'),
     registry = require('./registry/registry'),
-    pluginMappernto = require('cordova-registry-mapper').newToOld,
-    pluginMapperotn = require('cordova-registry-mapper').oldToNew,
     pluginSpec      = require('../cordova/plugin_spec_parser'),
     fetch = require('cordova-fetch'),
     cordovaUtil = require('../cordova/util');
@@ -170,13 +168,6 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
             }
             // If not found in local search path, fetch from the registry.
             var parsedSpec = pluginSpec.parse(plugin_src);
-            var newID = parsedSpec.scope ? null : pluginMapperotn[parsedSpec.id];
-            if(newID) {
-                plugin_src = newID;
-                if (parsedSpec.version) {
-                    plugin_src += '@' + parsedSpec.version;
-                }
-            }
             var P, skipCopyingPlugin;
             plugin_dir = path.join(plugins_dir, parsedSpec.id);
             // if the plugin has already been fetched, use it.
@@ -184,30 +175,19 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
                 P = Q(plugin_dir);
                 skipCopyingPlugin = true;
             } else {
-                // if the plugin alias has already been fetched, use it.
-                var alias = parsedSpec.scope ? null : pluginMappernto[parsedSpec.id] || newID;
-                if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
-                    events.emit('warn', 'Found '+alias+' is already fetched. Skipped fetching
' + parsedSpec.id);
-                    P = Q(path.join(plugins_dir, alias));
-                    skipCopyingPlugin = true;
-                } else {
-                    if (newID) {
-                        events.emit('warn', 'Notice: ' + parsedSpec.id + ' has been automatically
converted to ' + newID + ' to be fetched from npm. This is due to our old plugins registry
shutting down.');
-                    }
-                    //use cordova-fetch if --fetch was passed in
-                    if(options.fetch) {
-                        projectRoot = path.join(plugins_dir, '..');
-                        //Plugman projects need to go up two directories to reach project
root. 
-                        //Plugman projects have an options.projectRoot variable
-                        if(options.projectRoot) {
-                            projectRoot = options.projectRoot;
-                        }
-                        P = fetch(plugin_src, projectRoot, options); 
-                    } else {
-                        P = registry.fetch([plugin_src]);
+                //use cordova-fetch if --fetch was passed in
+                if(options.fetch) {
+                    projectRoot = path.join(plugins_dir, '..');
+                    //Plugman projects need to go up two directories to reach project root.

+                    //Plugman projects have an options.projectRoot variable
+                    if(options.projectRoot) {
+                        projectRoot = options.projectRoot;
                     }
-                    skipCopyingPlugin = false;
+                    P = fetch(plugin_src, projectRoot, options); 
+                } else {
+                    P = registry.fetch([plugin_src]);
                 }
+                skipCopyingPlugin = false;
             }
             return P
             .fail(function (error) {
@@ -257,11 +237,9 @@ function checkID(expectedIdAndVersion, pinfo) {
     var parsedSpec = pluginSpec.parse(expectedIdAndVersion);
 
     if (parsedSpec.id != pinfo.id) {
-        var alias = parsedSpec.scope ? null : pluginMappernto[parsedSpec.id] || pluginMapperotn[parsedSpec.id];
-        if (alias !== pinfo.id) {
-            throw new Error('Expected plugin to have ID "' + parsedSpec.id + '" but got "'
+ pinfo.id + '".');
-        }
+        throw new Error('Expected plugin to have ID "' + parsedSpec.id + '" but got "' +
pinfo.id + '".');
     }
+    
     if (parsedSpec.version && !semver.satisfies(pinfo.version, parsedSpec.version))
{
         throw new Error('Expected plugin ' + pinfo.id + ' to satisfy version "' + parsedSpec.version
+ '" but got "' + pinfo.version + '".');
     }
@@ -340,19 +318,6 @@ function copyPlugin(pinfo, plugins_dir, link) {
 
     var plugin_dir = pinfo.dir;
     var dest = path.join(plugins_dir, pinfo.id);
-    var altDest;
-
-    //check if alternative id already exists in plugins directory
-    if(pluginMapperotn[pinfo.id]) {
-        altDest = path.join(plugins_dir, pluginMapperotn[pinfo.id]);
-    } else if(pluginMappernto[pinfo.id]) {
-        altDest = path.join(plugins_dir, pluginMappernto[pinfo.id]);
-    }
-
-    if(fs.existsSync(altDest)) {
-        events.emit('log', pinfo.id + '" will not be added because its alternate id "' +
altDest + '" is already present.');
-        return altDest;
-    }
 
     shell.rm('-rf', dest);
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index e0d82bc..b555d4b 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -36,7 +36,6 @@ var path = require('path'),
     plugman = require('./plugman'),
     HooksRunner = require('../hooks/HooksRunner'),
     isWindows = (os.platform().substr(0,3) === 'win'),
-    pluginMapper = require('cordova-registry-mapper'),
     pluginSpec = require('../cordova/plugin_spec_parser'),
     cordovaUtil = require('../cordova/util');
 
@@ -87,16 +86,6 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
 // Returns a promise.
 function possiblyFetch(id, plugins_dir, options) {
     var parsedSpec = pluginSpec.parse(id);
-    //Check if a mapping exists for the plugin id
-    //if it does, convert id to new name id
-    var newId = parsedSpec.scope ? null : pluginMapper.oldToNew[parsedSpec.id];
-    if(newId) {
-        if(parsedSpec.version) {
-            id = newId + '@' + parsedSpec.version;
-        } else {
-            id = newId;
-        }
-    }
 
     // if plugin is a relative path, check if it already exists
     var plugin_src_dir = isAbsolutePath(id) ? id : path.join(plugins_dir, parsedSpec.id);
@@ -105,18 +94,7 @@ function possiblyFetch(id, plugins_dir, options) {
     if (fs.existsSync(plugin_src_dir)) {
         return Q(plugin_src_dir);
     }
-
-    var alias =  parsedSpec.scope ? null : pluginMapper.newToOld[parsedSpec.id] || newId;
-    // if the plugin alias has already been fetched, use it.
-    if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
-        events.emit('warn', 'Plugin with alternate id ' + alias + ' is already fetched, so
installing it instead of ' + parsedSpec.id);
-        return Q(path.join(plugins_dir, alias));
-    }
-
-    // if plugin doesnt exist, use fetch to get it.
-    if (newId) {
-        events.emit('warn', 'Notice: ' + parsedSpec.id + ' has been automatically converted
to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
-    }
+    
     var opts = underscore.extend({}, options, {
         client: 'plugman'
     });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43d7eaf2/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 06b02f5..02a615d 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -1,3 +1,4 @@
+
     /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -33,9 +34,7 @@ var path = require('path'),
     promiseutil = require('../util/promise-util'),
     HooksRunner = require('../hooks/HooksRunner'),
     cordovaUtil = require('../cordova/util'),
-    pluginMapper = require('cordova-registry-mapper').oldToNew,
-    npmUninstall = require('cordova-fetch').uninstall,
-    pluginSpec = require('../cordova/plugin_spec_parser');
+    npmUninstall = require('cordova-fetch').uninstall;
 
 var superspawn = require('cordova-common').superspawn;
 var PlatformJson = require('cordova-common').PlatformJson;
@@ -161,18 +160,8 @@ 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) {
-            var parsedSpec = pluginSpec.parse(d.id);
-            deps_path = path.join(plugin_dir, '..', parsedSpec.id);
-            if (!fs.existsSync(deps_path)) {
-                var newId = parsedSpec.scope ? null : pluginMapper[parsedSpec.id];
-                if (newId && toDelete.indexOf(newId) === -1) {
-                   events.emit('verbose', 'Automatically converted ' + d.id + ' to ' + newId
+ 'for uninstallation.');
-                   toDelete.push(newId);
-                   findDependencies(newId);
-                }
-            } else if (toDelete.indexOf(d.id) === -1) {
+            if (toDelete.indexOf(d.id) === -1) {
                 toDelete.push(d.id);
                 findDependencies(d.id);
             }
@@ -284,17 +273,6 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir,
plugin
         events.emit('log', 'Uninstalling ' + danglers.length + ' dependent plugins.');
         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 parsedSpec = pluginSpec.parse(dangler);
-                var newId = parsedSpec.scope ? null : pluginMapper[parsedSpec.id];
-                if(newId) {
-                    dependent_path = path.join(plugins_dir, newId);
-                    events.emit('verbose', 'Automatically converted ' + dangler + ' to '
+ newId + 'for uninstallation.');
-                }
-            }
-
             var opts = underscore.extend({}, options, {
                 is_top_level: depsInfo.top_level_plugins.indexOf(dangler) > -1,
                 depsInfo: depsInfo


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


Mime
View raw message