From e0c35cc28e3a4acdd89c36017d62d243eea10ec2 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Fri, 3 Oct 2014 18:05:59 -0700 Subject: [PATCH 1/5] Fix syntax of stdio inherit directive --- tools/commands-cordova.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index 6f6e1e46aa..ce6177bcc0 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -2226,7 +2226,7 @@ main.registerCommand({ if (args.length) { var arg = args[0]; if (arg == "adb") { - Android.runAdb(args.slice(1), { pipeOutput: true, detached: true, stdio: ['inherit', 'inherit', 'inherit']}); + Android.runAdb(args.slice(1), { pipeOutput: true, detached: true, stdio: 'inherit' }); } } From 0ee76cf5f7f38b8fbcaf282673704767c6af047f Mon Sep 17 00:00:00 2001 From: Justin SB Date: Fri, 3 Oct 2014 18:27:14 -0700 Subject: [PATCH 2/5] Log error from running command, if one is thrown --- tools/processes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/processes.js b/tools/processes.js index e208733f4b..ff9955f83c 100644 --- a/tools/processes.js +++ b/tools/processes.js @@ -49,6 +49,7 @@ _.extend(RunCommand.prototype, { }); self.process.on('error', function (err) { + Console.debug("Error while running command", err); self.exitError = err; self.exitFuture.isResolved() || self.exitFuture['throw'](err); }); From 246a3026a3c3143297e2b14faaa078bb8f25538f Mon Sep 17 00:00:00 2001 From: Justin SB Date: Fri, 3 Oct 2014 18:45:15 -0700 Subject: [PATCH 3/5] Bump SHA for com.meteor.cordova-update --- packages/meteor-platform/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/meteor-platform/package.js b/packages/meteor-platform/package.js index 43c4882174..878f43df7d 100644 --- a/packages/meteor-platform/package.js +++ b/packages/meteor-platform/package.js @@ -68,5 +68,5 @@ Package.on_use(function(api) { Cordova.depends({ 'org.apache.cordova.device': '0.2.11', - 'com.meteor.cordova-update': 'https://github.com/meteor/com.meteor.cordova-update/tarball/c3c3192ca318105c7aca6627a42e9a4b0ffb1f36' + 'com.meteor.cordova-update': 'https://github.com/meteor/com.meteor.cordova-update/tarball/92fe99b7248075318f6446b288995d4381d24cd2' }); From 0c7a12d482bb5d394564fd40defba6d60298119d Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Fri, 3 Oct 2014 19:21:50 -0700 Subject: [PATCH 4/5] Cordova.js is always served on root --- packages/boilerplate-generator/boilerplate_web.cordova.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/boilerplate-generator/boilerplate_web.cordova.html b/packages/boilerplate-generator/boilerplate_web.cordova.html index da6e53ff2c..d4cd0be029 100644 --- a/packages/boilerplate-generator/boilerplate_web.cordova.html +++ b/packages/boilerplate-generator/boilerplate_web.cordova.html @@ -21,7 +21,7 @@ } - + {{#each js}} {{/each}} {{#each additionalStaticJs}} From 94074d597260ef18b2b0b8a1657ad18d2ad03cdc Mon Sep 17 00:00:00 2001 From: Sashko Stubailo Date: Fri, 3 Oct 2014 21:06:22 -0700 Subject: [PATCH 5/5] Very carefully handle all of the different cases for servers and ports 1. mobile-server passed 2. running on device 3. running on simulator --- tools/commands.js | 2 +- tools/tests/utils-tests.js | 26 ++++++++++++++++--- tools/utils.js | 52 +++++++++++++++++++++++++++++--------- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/tools/commands.js b/tools/commands.js index 38bf5d4c0d..e509379aca 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -256,7 +256,7 @@ function doRunCommand (options) { } // If we are targeting the remote devices, warn about ports and same network - if (_.intersection(options.args, ['ios-device', 'android-device']).length) { + if (utils.runOnDevice(options)) { cordova.verboseLog('A run on a device requested'); var warning = [ "WARNING: You are testing your app on a remote device.", diff --git a/tools/tests/utils-tests.js b/tools/tests/utils-tests.js index fa58768467..c8f7808056 100644 --- a/tools/tests/utils-tests.js +++ b/tools/tests/utils-tests.js @@ -127,14 +127,34 @@ selftest.define("parse url", function () { }); selftest.define('get mobile server argument for meteor run', function () { - // meteor run -p 3000 => mobile server should be :3000 + // on emulator + + // meteor run -p 3000 + // => mobile server should be localhost:3000 selftest.expectEqual(utils.mobileServerForRun({ port: "3000" - }), { host: utils.ipAddress(), port: "3000", protocol: "http://" }); + }), { host: "localhost", port: "3000", protocol: "http://" }); - // meteor run -p example.com:3000 => mobile server should be :3000 + // meteor run -p example.com:3000 + // => mobile server should be localhost:3000 selftest.expectEqual(utils.mobileServerForRun({ port: "example.com:3000" + }), { host: "localhost", port: "3000", protocol: "http://" }); + + // on device + + // meteor run -p 3000 on device + // => mobile server should be :3000 + selftest.expectEqual(utils.mobileServerForRun({ + port: "3000", + args: ["ios-device"] + }), { host: utils.ipAddress(), port: "3000", protocol: "http://" }); + + // meteor run -p example.com:3000 on device + // => mobile server should be :3000 + selftest.expectEqual(utils.mobileServerForRun({ + port: "example.com:3000", + args: ["android-device"] }), { host: utils.ipAddress(), port: "3000", protocol: "http://" }); // meteor run -p example.com:3000 --mobile-server 4000 => error, mobile diff --git a/tools/utils.js b/tools/utils.js index 74384ac194..e10dae3d13 100644 --- a/tools/utils.js +++ b/tools/utils.js @@ -638,6 +638,12 @@ _.extend(exports.Patience.prototype, { } }); +// Are we running on device? +exports.runOnDevice = function (options) { + return !! _.intersection(options.args, + ['ios-device', 'android-device']).length; +}; + // Given the options for a 'meteor run' command, returns a parsed URL ({ // host: *, protocol: *, port: * }. The rules for --mobile-server are: // * If you don't specify anything for --mobile-server, then it @@ -645,6 +651,12 @@ _.extend(exports.Patience.prototype, { // * If you specify something for --mobile-server, we use that, // defaulting to http:// as the protocol and 80 or 443 as the port. exports.mobileServerForRun = function (options) { + // we want to do different IP generation depending on whether we + // are running for a device or simulator + options = _.extend({}, options, { + runOnDevice: exports.runOnDevice(options) + }); + var parsedUrl = parseUrl(options.port); if (! parsedUrl.port) { throw new Error("--port must include a port."); @@ -652,9 +664,26 @@ exports.mobileServerForRun = function (options) { // XXX COMPAT WITH 0.9.2.2 -- the 'mobile-port' option is deprecated var mobileServer = options["mobile-server"] || options["mobile-port"]; - var parsedMobileServer; - if (! mobileServer) { + + // if we specified a mobile server, use that + + if (mobileServer) { + var parsedMobileServer = parseUrl(mobileServer, { + protocol: "http://" + }); + + if (! parsedMobileServer.host) { + throw new Error("--mobile-server must specify a hostname."); + } + + return parsedMobileServer; + } + + + // if we are running on a device, use the auto-detected IP + + if (options.runOnDevice) { var myIp = ipAddress(); if (! myIp) { throw new Error( @@ -663,20 +692,19 @@ exports.mobileServerForRun = function (options) { "to with --mobile-server."); } - parsedMobileServer = { + return { host: myIp, port: parsedUrl.port, protocol: "http://" }; - } else { - parsedMobileServer = parseUrl(mobileServer, { - protocol: "http://" - }); - - if (! parsedMobileServer.host) { - throw new Error("--mobile-server must specify a hostname."); - } } - return parsedMobileServer; + + // we are running a simulator, use localhost:3000 + + return { + host: "localhost", + port: parsedUrl.port, + protocol: "http://" + }; };