diff --git a/README.md b/README.md index cc5d6d758..3c658a2cd 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... diff --git a/package.json b/package.json index 0edd24123..da12bee2b 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" diff --git a/spec/lazy_load.spec.js b/spec/lazy_load.spec.js index 16052402e..b5a54488c 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() { diff --git a/src/lazy_load.js b/src/lazy_load.js index 193f89525..aeda16932 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