cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [01/12] cordova-lib git commit: plugins get fetched from npm, then cordova registry if needed
Date Tue, 03 Mar 2015 07:37:36 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/CB-8551 [created] 9370401b6


plugins get fetched from npm, then cordova registry if needed


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

Branch: refs/heads/CB-8551
Commit: 4cf298cab1af6b02ddb9ee96df597bfe5ef5b1d3
Parents: 049548a
Author: Steve Gill <stevengill97@gmail.com>
Authored: Fri Jan 23 17:19:43 2015 -0800
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Fri Jan 23 17:20:15 2015 -0800

----------------------------------------------------------------------
 cordova-lib/package.json                     |  9 +--
 cordova-lib/src/plugman/registry/registry.js | 78 +++++++++++++++--------
 2 files changed, 58 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4cf298ca/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 70ded65..47543ae 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -18,6 +18,9 @@
   "engineStrict": true,
   "dependencies": {
     "bplist-parser": "0.0.6",
+    "cordova-js": "3.7.3",
+    "cordova-registry-mapper": "0.0.2",
+    "d8": "0.4.4",
     "dep-graph": "1.1.0",
     "elementtree": "0.1.5",
     "glob": "4.0.6",
@@ -33,13 +36,11 @@
     "semver": "2.0.11",
     "shelljs": "0.3.0",
     "tar": "1.0.2",
+    "through2": "0.6.3",
     "underscore": "1.7.0",
-    "xcode": "0.6.7",
-    "cordova-js": "3.7.3",
-    "d8": "0.4.4",
     "unorm": "1.3.3",
     "valid-identifier": "0.0.1",
-    "through2": "0.6.3"
+    "xcode": "0.6.7"
   },
   "devDependencies": {
     "istanbul": "^0.3.4",

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4cf298ca/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 3643eb3..a9ce9ab 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -30,6 +30,7 @@ var npm = require('npm'),
     rc = require('rc'),
     Q = require('q'),
     request = require('request'),
+    pluginMapper = require('cordova-registry-mapper');
     home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
     events = require('../../events'),
     unpack = require('../../util/unpack'),
@@ -327,7 +328,6 @@ function makeRequest (method, where, what, cb_) {
      * @return {Promise.<string>} Promised path to fetched package.
      */
 function fetchNPM(plugin, client) {
-    events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
     return initSettingsNPM()
     .then(function (settings) {
         return Q.nfcall(npm.load)
@@ -338,7 +338,35 @@ function fetchNPM(plugin, client) {
             }
         });
     })
+    .then(function(){
+        //if plugin variable is in reverse domain name style, look up the package-name in
cordova-registry-mapper module
+
+        //Create regex to for digits, words and dashes and three dots in plugin ids which
excludes @VERSION.
+        var re = /([\w-]*\.[\w-]*\.[\w-]*\.[\w-]*[^@])/;
+        var pluginID = plugin.match(re);
+        //If true, pluginID is reverse domain style
+        if(pluginID != null) { 
+            //grab the @VERSION from the end of the plugin string if it exists
+            re = /(@.*)/;
+            var versionStr = plugin.match(re);
+
+            //Check if a mapping exists for the pluginID
+            //if it does, set the plugin variable to your packageName
+            //if it doesn't, don't change the plugin variable
+            var packageName = pluginMapper[pluginID[0]];
+            if(packageName) {
+                //if @VERSION exists, concat it to packageName
+                if(versionStr != null) {
+                    packageName += versionStr[0];
+                }
+                events.emit('verbose', 'Converted ' + plugin + ' to ' + packageName + ' for
npm fetch');
+                plugin = packageName;
+            }
+        }
+        return true;
+    })
     .then(function() {
+        events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
         return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
     })
     .then(function(info) {
@@ -358,30 +386,30 @@ function fetchNPM(plugin, client) {
  * @return {Promise.<string>} Promised path to fetched package.
  */
 function fetchPlugReg(plugin, client) {
-    events.emit('log', 'Fetching plugin "' + plugin + '" via plugin registry');
-        return initSettings()
-        .then(function (settings) {
-            return Q.nfcall(npm.load)
-            // configure npm here instead of passing parameters to npm.load due to CB-7670
-            .then(function () {
-                for (var prop in settings){
-                    npm.config.set(prop, settings[prop]);
-                }
-            });
-        })
-        .then(function() {
-            return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
-        })
-        .then(function(info) {
-            var cl = (client === 'plugman' ? 'plugman' : 'cordova-cli');
-            bumpCounter(info, cl);
-            var pluginDir = path.resolve(npm.cache, info.name, info.version, 'package');
-            // Unpack the plugin that was added to the cache (CB-8154)
-            var package_tgz = path.resolve(npm.cache, info.name, info.version, 'package.tgz');
-            return unpack.unpackTgz(package_tgz, pluginDir);
-        })
-        .fail(function() {
-            events.emit('log', 'Fetching from plugin registry failed');
+    return initSettings()
+    .then(function (settings) {
+        return Q.nfcall(npm.load)
+        // configure npm here instead of passing parameters to npm.load due to CB-7670
+        .then(function () {
+            for (var prop in settings){
+                npm.config.set(prop, settings[prop]);
+            }
         });
+    })
+    .then(function() {
+        events.emit('log', 'Fetching plugin "' + plugin + '" via plugin registry');
+        return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
+    })
+    .then(function(info) {
+        var cl = (client === 'plugman' ? 'plugman' : 'cordova-cli');
+        bumpCounter(info, cl);
+        var pluginDir = path.resolve(npm.cache, info.name, info.version, 'package');
+        // Unpack the plugin that was added to the cache (CB-8154)
+        var package_tgz = path.resolve(npm.cache, info.name, info.version, 'package.tgz');
+        return unpack.unpackTgz(package_tgz, pluginDir);
+    })
+    .fail(function() {
+        events.emit('log', 'Fetching from plugin registry failed');
+    });
 }
 


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


Mime
View raw message