cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject git commit: [CB-4322] Use npms proxy configuration (if set) in the lazy load module. Added proxy verbiage to README. Bumped dependency on plugman to 0.9.11. Bumped version to 3.0.1.
Date Wed, 24 Jul 2013 22:54:57 GMT
Updated Branches:
  refs/heads/master a5f40b2fa -> 1148e6f73


[CB-4322] Use npms proxy configuration (if set) in the lazy load module. Added proxy verbiage
to README. Bumped dependency on plugman to 0.9.11. Bumped version to 3.0.1.


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

Branch: refs/heads/master
Commit: 1148e6f73b0f9fba8ef4706fae876113dc9a85a9
Parents: a5f40b2
Author: Fil Maj <maj.fil@gmail.com>
Authored: Wed Jul 24 15:54:46 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed Jul 24 15:54:46 2013 -0700

----------------------------------------------------------------------
 README.md              | 11 ++++++++++-
 package.json           |  7 ++++---
 spec/lazy_load.spec.js | 24 ++++++++++++++++++++++++
 src/lazy_load.js       | 23 +++++++++++++++++++----
 4 files changed, 57 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1148e6f7/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index cc5d6d7..3c658a2 100644
--- a/README.md
+++ b/README.md
@@ -182,7 +182,16 @@ Thanks to everyone for contributing! For a list of people involved, please
see t
 
 # Known Issues and Troubleshooting
 
-##Windows
+## Any OS
+
+### Proxy Settings
+
+cordova-cli will use `npm`'s proxy settings. If you downloaded cordova-cli via `npm` and
are behind a proxy, chances are cordova-cli should work for you as it will use those settings
in the first place. Make sure that the `https-proxy` and `proxy` npm config variables are
set properly. See [npm's configuration documentation](https://npmjs.org/doc/config.html) for
more information.
+
+## Windows
+
+### Trouble Adding Android as a Platform
+
 When trying to add a platform on a Windows machine if you run into the following error message:
     cordova library for "android" already exists. No need to download. Continuing.
     Checking if platform "android" passes minimum requirements...

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1148e6f7/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 0edd241..da12bee 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "3.0.0",
+  "version": "3.0.1",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",
@@ -30,7 +30,7 @@
   "dependencies": {
     "colors":">=0.6.0",
     "elementtree":"0.1.3",
-    "plugman":"0.9.10",
+    "plugman":"0.9.11",
     "plist":"0.4.x",
     "xcode":"0.5.1",
     "express":"3.0.0",
@@ -43,7 +43,8 @@
     "follow-redirects":"0.0.x",
     "prompt":"0.2.7",
     "tar":"0.1.x",
-    "open": "0.0.3"
+    "open": "0.0.3",
+    "npm":"1.3.x"
   },
   "devDependencies": {
     "jasmine-node":"1.8.x"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1148e6f7/spec/lazy_load.spec.js
----------------------------------------------------------------------
diff --git a/spec/lazy_load.spec.js b/spec/lazy_load.spec.js
index 1605240..b5a5448 100644
--- a/spec/lazy_load.spec.js
+++ b/spec/lazy_load.spec.js
@@ -2,6 +2,7 @@ var lazy_load = require('../src/lazy_load'),
     config = require('../src/config'),
     util = require('../src/util'),
     shell = require('shelljs'),
+    npm = require('npm');
     path = require('path'),
     hooker = require('../src/hooker'),
     request = require('request'),
@@ -56,6 +57,7 @@ describe('lazy_load module', function() {
 
         describe('remote URLs for libraries', function() {
             var req,
+                load_spy,
                 p1 = jasmine.createSpy().andReturn({
                     on:function() {
                         return {
@@ -68,6 +70,8 @@ describe('lazy_load module', function() {
                 req = spyOn(request, 'get').andReturn({
                     pipe:p2
                 });
+                load_spy = spyOn(npm, 'load').andCallFake(function(cb) { cb(); });
+                npm.config.get = function() { return null; };
             });
 
             it('should call request with appopriate url params', function() {
@@ -77,6 +81,26 @@ describe('lazy_load module', function() {
                     uri:url
                 }, jasmine.any(Function));
             });
+            it('should take into account https-proxy npm configuration var if exists for
https:// calls', function() {
+                var proxy = 'https://somelocalproxy.com';
+                npm.config.get = function() { return proxy; };
+                var url = 'https://github.com/apache/someplugin';
+                lazy_load.custom(url, 'random', 'android', '1.0');
+                expect(req).toHaveBeenCalledWith({
+                    uri:url,
+                    proxy:proxy
+                }, jasmine.any(Function));
+            });
+            it('should take into account proxy npm config var if exists for http:// calls',
function() {
+                var proxy = 'http://somelocalproxy.com';
+                npm.config.get = function() { return proxy; };
+                var url = 'http://github.com/apache/someplugin';
+                lazy_load.custom(url, 'random', 'android', '1.0');
+                expect(req).toHaveBeenCalledWith({
+                    uri:url,
+                    proxy:proxy
+                }, jasmine.any(Function));
+            });
         });
 
         describe('local paths for libraries', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1148e6f7/src/lazy_load.js
----------------------------------------------------------------------
diff --git a/src/lazy_load.js b/src/lazy_load.js
index 193f895..aeda169 100644
--- a/src/lazy_load.js
+++ b/src/lazy_load.js
@@ -20,6 +20,7 @@ var path          = require('path'),
     fs            = require('fs'),
     shell         = require('shelljs'),
     platforms     = require('../platforms'),
+    npm           = require('npm'),
     events        = require('./events'),
     request       = require('request'),
     config        = require('./config'),
@@ -64,10 +65,23 @@ module.exports = {
         }, function() {
             var uri = URL.parse(url);
             if (uri.protocol && uri.protocol[1] != ':') { // second part of conditional
is for awesome windows support. fuuu windows
-                shell.mkdir('-p', download_dir);
-                events.emit('log', 'Requesting ' + url + '...');
-                var size = 0;
-                request.get({uri:url}, function(err, req, body) { size = body.length; })
+                npm.load(function() {
+                    // Check if NPM proxy settings are set. If so, include them in the request()
call.
+                    var proxy;
+                    if (uri.protocol == 'https:') {
+                        proxy = npm.config.get('https-proxy');
+                    } else if (uri.protocol == 'http:') {
+                        proxy = npm.config.get('proxy');
+                    }
+
+                    shell.mkdir('-p', download_dir);
+                    var size = 0;
+                    var request_options = {uri:url};
+                    if (proxy) {
+                        request_options.proxy = proxy;
+                    }
+                    events.emit('log', 'Requesting ' + JSON.stringify(request_options) +
'...');
+                    request.get(request_options, function(err, req, body) { size = body.length;
})
                     .pipe(zlib.createUnzip())
                     .pipe(tar.Extract({path:download_dir}))
                     .on('error', function(err) {
@@ -91,6 +105,7 @@ module.exports = {
                         }, function() {
                             if (callback) callback();
                         });
+                    });
                 });
             } else {
                 // local path


Mime
View raw message