You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2018/11/24 17:57:55 UTC

[cordova-paramedic] branch johanlantz updated (2b3e03f -> 04b6204)

This is an automated email from the ASF dual-hosted git repository.

janpio pushed a change to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git.


    from 2b3e03f  [CB-12210] require a string when parsing the plugin argument. (#19)
     new f216707  Prefer physical dev (#2)
     new 2d1ff2c  get server ip automatically (#3)
     new 9b5f75c  manage android permissions (#4)
     new d726584  add missing physical device function
     new 4997a3e  Ensure output is posted to console after child process finishes (#5)
     new 04b6204  device is real device, not emulator with device tag

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 lib/ParamedicConfig.js        | 11 ++++++++++-
 lib/ParamedicTargetChooser.js | 10 +++++++++-
 lib/paramedic.js              | 28 ++++++++++++++++++++++++++--
 lib/utils/utilities.js        | 20 ++++++++++++++++++++
 4 files changed, 65 insertions(+), 4 deletions(-)


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


[cordova-paramedic] 02/06: get server ip automatically (#3)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit 2d1ff2c99054518990b2109a3f0a3676493fdbd8
Author: johanlantz <il...@gmail.com>
AuthorDate: Wed Jun 13 18:07:12 2018 +0200

    get server ip automatically (#3)
---
 lib/ParamedicConfig.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/ParamedicConfig.js b/lib/ParamedicConfig.js
index ad8d627..2a4aacb 100644
--- a/lib/ParamedicConfig.js
+++ b/lib/ParamedicConfig.js
@@ -30,6 +30,8 @@ var BROWSERIFY_ARG                         = '--browserify ';
 var DEFAULT_CLI                            = 'cordova'; // use globally installed cordova by default
 
 var util = require('./utils').utilities;
+var ip = require('ip');
+var logger = require('./utils').logger;
 
 function ParamedicConfig(json) {
     this._config = json;
@@ -152,7 +154,14 @@ ParamedicConfig.prototype.setPlugins = function (plugins) {
 };
 
 ParamedicConfig.prototype.getExternalServerUrl = function () {
-    return this._config.externalServerUrl;
+    if (this._config.externalServerUrl) {
+        return this._config.externalServerUrl;
+    } else {
+       // Android emulator defaults to 10.0.0.2 for some reason. If that is needed, it must be passed using the externalServerUrl parameter
+        var serverIp = "http://" + ip.address();
+        logger.info("Using local server address = " + serverIp);
+        return serverIp;
+    }
 };
 
 ParamedicConfig.prototype.isVerbose = function () {


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


[cordova-paramedic] 04/06: add missing physical device function

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit d7265846dd8ade47ed34b5c6c53f19c55525e331
Author: Johan Lantz <jo...@telefonica.com>
AuthorDate: Wed Jun 20 16:46:15 2018 +0200

    add missing physical device function
---
 lib/utils/utilities.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index a2c7fbb..5970c33 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -29,6 +29,7 @@ var kill    = require('tree-kill');
 
 var HEADING_LINE_PATTERN = /List of devices/m;
 var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
+var DEVICE_ONLY_ROW_PATTERN   = /(device)/m;
 
 var KILL_SIGNAL = 'SIGINT';
 
@@ -52,6 +53,24 @@ function countAndroidDevices() {
     return numDevices;
 }
 
+function getAndroidPhysicalDevice() {
+    var listCommand = 'adb devices';
+
+    logger.info('running:');
+    logger.info('    ' + listCommand);
+
+    var numDevices = 0;
+    var result = shelljs.exec(listCommand, {silent: false, async: false});
+    var deviceId = null;
+    result.output.split('\n').forEach(function (line) {
+        if (!HEADING_LINE_PATTERN.test(line) && DEVICE_ONLY_ROW_PATTERN.test(line)) {
+            deviceId = line.split('\t')[0];
+            logger.info("Identified deviceId as: " + deviceId);
+        }
+    });
+    return deviceId;
+}
+
 function secToMin(seconds) {
     return Math.ceil(seconds / 60);
 }
@@ -218,6 +237,7 @@ module.exports = {
     secToMin: secToMin,
     isWindows:  isWindows,
     countAndroidDevices: countAndroidDevices,
+    getAndroidPhysicalDevice: getAndroidPhysicalDevice,
     getSimulatorsFolder: getSimulatorsFolder,
     doesFileExist: doesFileExist,
     getSqlite3InsertionCommand: getSqlite3InsertionCommand,


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


[cordova-paramedic] 06/06: device is real device, not emulator with device tag

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit 04b6204aa08e9f3b314326640f1c3c8e979df475
Author: Johan Lantz <jo...@telefonica.com>
AuthorDate: Fri Jun 22 12:29:48 2018 +0200

    device is real device, not emulator with device tag
---
 lib/utils/utilities.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index 5970c33..4e99af6 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -29,7 +29,7 @@ var kill    = require('tree-kill');
 
 var HEADING_LINE_PATTERN = /List of devices/m;
 var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
-var DEVICE_ONLY_ROW_PATTERN   = /(device)/m;
+var DEVICE_ONLY_ROW_PATTERN   = /(^(?!.*(emulator)).*device.*$)/m;
 
 var KILL_SIGNAL = 'SIGINT';
 


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


[cordova-paramedic] 03/06: manage android permissions (#4)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit 9b5f75c55239dbc0fc55233943c6eedb40f59b3d
Author: johanlantz <il...@gmail.com>
AuthorDate: Wed Jun 20 14:56:51 2018 +0200

    manage android permissions (#4)
---
 lib/paramedic.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/paramedic.js b/lib/paramedic.js
index a386bb7..591949f 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -244,6 +244,20 @@ ParamedicRunner.prototype.setPermissions = function () {
             paramediciOSPermissions.updatePermissions(applicationsToGrantPermission);
         }
     }
+
+    if(this.config.getPlatformId() === util.ANDROID) {
+        var self = this;
+        self.server.on('jasmineStarted', function (data) {
+            logger.info('cordova-paramedic: Jasmine started');
+            logger.warn('Requesting permissions');
+            cp.exec("adb shell pm grant " + util.PARAMEDIC_DEFAULT_APP_NAME + " android.permission.READ_PHONE_STATE");
+            cp.exec("adb shell pm grant " + util.PARAMEDIC_DEFAULT_APP_NAME + " android.permission.READ_SMS");
+            cp.exec("adb shell pm grant " + util.PARAMEDIC_DEFAULT_APP_NAME + " android.permission.READ_CALL_LOG");
+            cp.exec("adb shell pm grant " + util.PARAMEDIC_DEFAULT_APP_NAME + " android.permission.ACCESS_FINE_LOCATION");
+            cp.exec("adb shell pm grant " + util.PARAMEDIC_DEFAULT_APP_NAME + " android.permission.ACCESS_COARSE_LOCATION");
+            cp.exec("adb shell pm grant " + util.PARAMEDIC_DEFAULT_APP_NAME + " android.permission.RECORD_AUDIO");
+        });
+    }
 };
 
 ParamedicRunner.prototype.injectReporters = function () {


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


[cordova-paramedic] 01/06: Prefer physical dev (#2)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit f21670734573191a108453f2547dce6ba6bd94b2
Author: johanlantz <il...@gmail.com>
AuthorDate: Wed Jun 13 17:17:37 2018 +0200

    Prefer physical dev (#2)
---
 lib/ParamedicTargetChooser.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/ParamedicTargetChooser.js b/lib/ParamedicTargetChooser.js
index 6b162ad..edc913f 100644
--- a/lib/ParamedicTargetChooser.js
+++ b/lib/ParamedicTargetChooser.js
@@ -59,7 +59,15 @@ ParamedicTargetChooser.prototype.chooseTargetForAndroid = function (emulator, ta
         var obj = {};
         obj.target = target;
         return obj;
-    } 
+    }
+
+    var connectedPhysicalDevice = util.getAndroidPhysicalDevice();
+    if (connectedPhysicalDevice) {
+        logger.info('cordova-paramedic: Physical device connected, use: ' + connectedPhysicalDevice);
+        var obj = {};
+        obj.target = connectedPhysicalDevice;
+        return obj;
+    }
     
     return this.startAnAndroidEmulator(target).then(function(emulatorId) {
         var obj = {};


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


[cordova-paramedic] 05/06: Ensure output is posted to console after child process finishes (#5)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit 4997a3eaa8ef955d4edda24bb073dc60f68f7bba
Author: johanlantz <il...@gmail.com>
AuthorDate: Fri Jun 22 10:36:01 2018 +0200

    Ensure output is posted to console after child process finishes (#5)
---
 lib/paramedic.js | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/paramedic.js b/lib/paramedic.js
index 591949f..45ca10d 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -346,8 +346,18 @@ ParamedicRunner.prototype.runLocalTests = function () {
         if (self.config.getPlatformId() !== util.BROWSER) {
             return execPromise(command);
         }
-        runProcess = cp.exec(command, function () {
-            // a precaution not to try to kill some other process
+        // We do not wait for the child process to finish, server connects when deployed and ready. 
+        runProcess = cp.exec(command, (error, stdout, stderr) => {     
+            if (error) {
+                // This won't show up until the process completes:
+                console.log('[ERROR]: Running cordova run failed');
+
+                console.log(stdout);
+                console.log(stderr);
+                reject(error);
+            }
+            console.log(stdout);
+            console.log(stderr);
             runProcess = null;
         });
     })


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