[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-27 Thread sarangan12
Github user sarangan12 commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r61334254
  
--- Diff: lib/ParamediciOSPermissions.js ---
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path = require('path');
+var fs   = require('fs');
+var shelljs  = require("shelljs");
+var logger   = require('./utils').logger;
+var util = require('./utils').utilities;
+
+var TCC_FOLDER_PERMISSION = 0777;
+
+function ParamediciOSPermissions(appName, tccDbPath) {
+this.appName = appName;
+this.tccDbPath = tccDbPath;
+}
+
+ParamediciOSPermissions.prototype.updatePermissions = 
function(serviceList){
+var simulatorsFolder   = util.getSimulatorsFolder();
+var simId  = util.getSimId();
+logger.info('Sim Id is: ' + simId);
+var destinationTCCFile = path.join(simulatorsFolder, simId, 
'/data/Library/TCC/TCC.db');
+
+if(!util.doesFileExist(destinationTCCFile)) {
+// No TCC.db file exists by default. So, Copy the new TCC.db file
+var destinationTCCFolder = path.join(simulatorsFolder, simId, 
'/data/Library/TCC');
+if(!util.doesFileExist(destinationTCCFolder)){
+fs.mkdir(destinationTCCFolder, TCC_FOLDER_PERMISSION);
+}
+var command = "cp " + this.tccDbPath + " " + destinationTCCFolder;
+logger.info("Running Command: " + command);
+shelljs.exec(command, {silent: true, async: false});
+}
--- End diff --

DOne


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-27 Thread sarangan12
Github user sarangan12 commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r61334214
  
--- Diff: lib/ParamedicConfig.js ---
@@ -36,8 +36,10 @@ ParamedicConfig.parseFromArguments = function (argv) {
 startPort: argv.startport || argv.port,
 endPort:   argv.endport || argv.port,
 externalServerUrl: argv.externalServerUrl,
-reportSavePath:!!argv.reportSavePath? argv.reportSavePath: 
undefined,
-cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false
+outputDir: !!argv.outputDir? argv.outputDir: null,
+cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false,
+logMins:   !!argv.logMins? argv.logMins: null,
--- End diff --

We are initializing it in paramedic.js


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-27 Thread sarangan12
Github user sarangan12 commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r61334368
  
--- Diff: lib/utils/utilities.js ---
@@ -0,0 +1,123 @@
+#!/usr/bin/env node
+
+var shelljs = require('shelljs');
+var verbose = undefined;
+var fs  = require('fs');
+var os  = require("os");
+var util= require('util');
+var path= require("path-extra");
+var logger  = require('cordova-common').CordovaLogger.get();
+
+var HEADING_LINE_PATTERN = /List of devices/m;
+var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
+
+function isWindows () {
+return /^win/.test(os.platform());
+}
+
+function countAndroidDevices() {
+var listCommand = "adb devices";
+
+logger.info("running:");
+logger.info("" + listCommand);
+
+var numDevices = 0;
+var result = shelljs.exec(listCommand, {silent: false, async: false});
+result.output.split('\n').forEach(function (line) {
+if (!HEADING_LINE_PATTERN.test(line) && 
DEVICE_ROW_PATTERN.test(line)) {
+numDevices += 1;
+}
+});
+return numDevices;
+}
+
+function secToMin (seconds) {
+return Math.ceil(seconds / 60);
+}
+
+function getSimulatorsFolder() {
+var simulatorsFolderPath = path.join(path.homedir(), "Library", 
"Developer", "CoreSimulator", "Devices");
+return simulatorsFolderPath;
+}
+
+function getSimId() {
+var findSimCommand = "cordova run --list --emulator | grep ^iPhone | 
tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+return simId;
+}
+
+function doesFileExist(filePath) {
+var fileExists = false;
+try {
+stats = fs.statSync(filePath);
+fileExists = true;
+} catch (e) {
+fileExists = false;
+}
+return fileExists;
+}
+
+function getSqlite3InsertionCommand(destinationTCCFile, service, appName) {
+return util.format( 'sqlite3 %s "insert into access'
+  + '(service, client, client_type, allowed, 
prompt_count, csreq) values(\'%s\', \'%s\', '
+  + '0,1,1,NULL)"', destinationTCCFile, service, 
appName);
+}
+
+module.exports = {
+ANDROID:"android",
+IOS:"ios",
+WINDOWS:"windows",
+PARAMEDIC_DEFAULT_APP_NAME: "io.cordova.hellocordova",
+
+DEFAULT_LOG_TIME: 15,
+DEFAULT_LOG_TIME_ADDITIONAL: 2,
+
+secToMin: secToMin,
+isWindows:  isWindows,
+countAndroidDevices: countAndroidDevices,
+getSimulatorsFolder: getSimulatorsFolder,
+getSimId: getSimId,
+doesFileExist: doesFileExist,
+getSqlite3InsertionCommand: getSqlite3InsertionCommand
+};
--- End diff --

This seems to be fine


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, 

[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-27 Thread sarangan12
Github user sarangan12 commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r61334311
  
--- Diff: lib/utils/utilities.js ---
@@ -0,0 +1,123 @@
+#!/usr/bin/env node
+
+var shelljs = require('shelljs');
+var verbose = undefined;
+var fs  = require('fs');
+var os  = require("os");
+var util= require('util');
+var path= require("path-extra");
+var logger  = require('cordova-common').CordovaLogger.get();
+
+var HEADING_LINE_PATTERN = /List of devices/m;
+var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
+
+function isWindows () {
+return /^win/.test(os.platform());
+}
+
+function countAndroidDevices() {
+var listCommand = "adb devices";
+
+logger.info("running:");
+logger.info("" + listCommand);
+
+var numDevices = 0;
+var result = shelljs.exec(listCommand, {silent: false, async: false});
+result.output.split('\n').forEach(function (line) {
+if (!HEADING_LINE_PATTERN.test(line) && 
DEVICE_ROW_PATTERN.test(line)) {
+numDevices += 1;
+}
+});
+return numDevices;
+}
+
+function secToMin (seconds) {
+return Math.ceil(seconds / 60);
+}
+
+function getSimulatorsFolder() {
+var simulatorsFolderPath = path.join(path.homedir(), "Library", 
"Developer", "CoreSimulator", "Devices");
+return simulatorsFolderPath;
+}
+
+function getSimId() {
+var findSimCommand = "cordova run --list --emulator | grep ^iPhone | 
tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+return simId;
+}
--- End diff --

Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-27 Thread sarangan12
Github user sarangan12 commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r61334228
  
--- Diff: lib/ParamedicConfig.js ---
@@ -36,8 +36,10 @@ ParamedicConfig.parseFromArguments = function (argv) {
 startPort: argv.startport || argv.port,
 endPort:   argv.endport || argv.port,
 externalServerUrl: argv.externalServerUrl,
-reportSavePath:!!argv.reportSavePath? argv.reportSavePath: 
undefined,
-cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false
+outputDir: !!argv.outputDir? argv.outputDir: null,
+cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false,
+logMins:   !!argv.logMins? argv.logMins: null,
+tccDbPath: !!argv.tccDbPath? argv.tccDbPath: null
--- End diff --

DOne


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-27 Thread sarangan12
Github user sarangan12 commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r61334170
  
--- Diff: lib/ParamediciOSPermissions.js ---
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path = require('path');
+var fs   = require('fs');
+var shelljs  = require("shelljs");
+var logger   = require('./utils').logger;
+var util = require('./utils').utilities;
+
+var TCC_FOLDER_PERMISSION = 0777;
--- End diff --

Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-20 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60495766
  
--- Diff: lib/utils/utilities.js ---
@@ -0,0 +1,123 @@
+#!/usr/bin/env node
+
+var shelljs = require('shelljs');
+var verbose = undefined;
+var fs  = require('fs');
+var os  = require("os");
+var util= require('util');
+var path= require("path-extra");
+var logger  = require('cordova-common').CordovaLogger.get();
+
+var HEADING_LINE_PATTERN = /List of devices/m;
+var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
+
+function isWindows () {
+return /^win/.test(os.platform());
+}
+
+function countAndroidDevices() {
+var listCommand = "adb devices";
+
+logger.info("running:");
+logger.info("" + listCommand);
+
+var numDevices = 0;
+var result = shelljs.exec(listCommand, {silent: false, async: false});
+result.output.split('\n').forEach(function (line) {
+if (!HEADING_LINE_PATTERN.test(line) && 
DEVICE_ROW_PATTERN.test(line)) {
+numDevices += 1;
+}
+});
+return numDevices;
+}
+
+function secToMin (seconds) {
+return Math.ceil(seconds / 60);
+}
+
+function getSimulatorsFolder() {
+var simulatorsFolderPath = path.join(path.homedir(), "Library", 
"Developer", "CoreSimulator", "Devices");
+return simulatorsFolderPath;
+}
+
+function getSimId() {
+var findSimCommand = "cordova run --list --emulator | grep ^iPhone | 
tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+return simId;
+}
+
+function doesFileExist(filePath) {
+var fileExists = false;
+try {
+stats = fs.statSync(filePath);
+fileExists = true;
+} catch (e) {
+fileExists = false;
+}
+return fileExists;
+}
+
+function getSqlite3InsertionCommand(destinationTCCFile, service, appName) {
+return util.format( 'sqlite3 %s "insert into access'
+  + '(service, client, client_type, allowed, 
prompt_count, csreq) values(\'%s\', \'%s\', '
+  + '0,1,1,NULL)"', destinationTCCFile, service, 
appName);
+}
+
+module.exports = {
+ANDROID:"android",
+IOS:"ios",
+WINDOWS:"windows",
+PARAMEDIC_DEFAULT_APP_NAME: "io.cordova.hellocordova",
+
+DEFAULT_LOG_TIME: 15,
+DEFAULT_LOG_TIME_ADDITIONAL: 2,
+
+secToMin: secToMin,
+isWindows:  isWindows,
+countAndroidDevices: countAndroidDevices,
+getSimulatorsFolder: getSimulatorsFolder,
+getSimId: getSimId,
+doesFileExist: doesFileExist,
+getSqlite3InsertionCommand: getSqlite3InsertionCommand
+};
--- End diff --

The name of this file is awkward. Consider just putting this code in 
`lib/utils.js`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail

[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-20 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60480780
  
--- Diff: lib/utils/utilities.js ---
@@ -0,0 +1,123 @@
+#!/usr/bin/env node
+
+var shelljs = require('shelljs');
+var verbose = undefined;
+var fs  = require('fs');
+var os  = require("os");
+var util= require('util');
+var path= require("path-extra");
+var logger  = require('cordova-common').CordovaLogger.get();
+
+var HEADING_LINE_PATTERN = /List of devices/m;
+var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
+
+function isWindows () {
+return /^win/.test(os.platform());
+}
+
+function countAndroidDevices() {
+var listCommand = "adb devices";
+
+logger.info("running:");
+logger.info("" + listCommand);
+
+var numDevices = 0;
+var result = shelljs.exec(listCommand, {silent: false, async: false});
+result.output.split('\n').forEach(function (line) {
+if (!HEADING_LINE_PATTERN.test(line) && 
DEVICE_ROW_PATTERN.test(line)) {
+numDevices += 1;
+}
+});
+return numDevices;
+}
+
+function secToMin (seconds) {
+return Math.ceil(seconds / 60);
+}
+
+function getSimulatorsFolder() {
+var simulatorsFolderPath = path.join(path.homedir(), "Library", 
"Developer", "CoreSimulator", "Devices");
+return simulatorsFolderPath;
+}
+
+function getSimId() {
+var findSimCommand = "cordova run --list --emulator | grep ^iPhone | 
tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+return simId;
+}
--- End diff --

So, turns out this regex breaks in Xcode 7.3, because of the 
```(Simulator)``` added at the end, I still think this code is too fragile as 
it depends on specific Xcode output, which might change in the future. Maybe, 
we should go back to searching through all folders like before ? 

In the meantime, reajusting the regex to ```var simIdRegex = /^([a-zA-Z\d 
]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\].*$/;``` fixes this issue.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-20 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60472155
  
--- Diff: lib/utils/utilities.js ---
@@ -0,0 +1,123 @@
+#!/usr/bin/env node
+
+var shelljs = require('shelljs');
+var verbose = undefined;
+var fs  = require('fs');
+var os  = require("os");
+var util= require('util');
+var path= require("path-extra");
+var logger  = require('cordova-common').CordovaLogger.get();
+
+var HEADING_LINE_PATTERN = /List of devices/m;
+var DEVICE_ROW_PATTERN   = /(emulator|device|host)/m;
+
+function isWindows () {
+return /^win/.test(os.platform());
+}
+
+function countAndroidDevices() {
+var listCommand = "adb devices";
+
+logger.info("running:");
+logger.info("" + listCommand);
+
+var numDevices = 0;
+var result = shelljs.exec(listCommand, {silent: false, async: false});
+result.output.split('\n').forEach(function (line) {
+if (!HEADING_LINE_PATTERN.test(line) && 
DEVICE_ROW_PATTERN.test(line)) {
+numDevices += 1;
+}
+});
+return numDevices;
+}
+
+function secToMin (seconds) {
+return Math.ceil(seconds / 60);
+}
+
+function getSimulatorsFolder() {
+var simulatorsFolderPath = path.join(path.homedir(), "Library", 
"Developer", "CoreSimulator", "Devices");
+return simulatorsFolderPath;
+}
+
+function getSimId() {
+var findSimCommand = "cordova run --list --emulator | grep ^iPhone | 
tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+return simId;
+}
--- End diff --

So, running this code, I face an issue where the simId returned is null.
Here's the output of various bash commands executed here:
- 
```
nstruments -s devices | grep ^iPhone
iPhone 4s (9.3) [93EC91E3-2679-49DC-AC6B-CAB279E462AF] (Simulator)
iPhone 5 (9.3) [830AC555-1986-4B48-82C7-898849A50541] (Simulator)
iPhone 5s (9.3) [17726EFF-F3B9-435E-8882-CC6ED589C213] (Simulator)
iPhone 6 (9.3) [3BDE39CD-7998-4959-B2D8-7C08C33B20B1] (Simulator)
iPhone 6 Plus (9.3) [7235ADB5-8730-4D0A-821F-5469D1ED47D7] (Simulator)
iPhone 6s (9.3) [32745196-42F6-4927-ADA0-16BACE15FC99] (Simulator)
iPhone 6s (9.3) + Apple Watch - 38mm (2.2) 
[6A868DF2-F36A-4AEE-9EC1-B956375934B9] (Simulator)
iPhone 6s Plus (9.3) [A949CB17-350F-4B28-AD64-425339ACEDBF] (Simulator)
iPhone 6s Plus (9.3) + Apple Watch - 42mm (2.2) 
[E0C9BC62-83AA-45C5-B411-FBCB557DE32B] (Simulator)
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60329456
  
--- Diff: lib/ParamediciOSPermissions.js ---
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path = require('path');
+var fs   = require('fs');
+var shelljs  = require("shelljs");
+var logger   = require('./utils').logger;
+var util = require('./utils').utilities;
+
+var TCC_FOLDER_PERMISSION = 0777;
+
+function ParamediciOSPermissions(appName, tccDbPath) {
+this.appName = appName;
+this.tccDbPath = tccDbPath;
+}
+
+ParamediciOSPermissions.prototype.updatePermissions = 
function(serviceList){
+var simulatorsFolder   = util.getSimulatorsFolder();
+var simId  = util.getSimId();
+logger.info('Sim Id is: ' + simId);
+var destinationTCCFile = path.join(simulatorsFolder, simId, 
'/data/Library/TCC/TCC.db');
+
+if(!util.doesFileExist(destinationTCCFile)) {
+// No TCC.db file exists by default. So, Copy the new TCC.db file
+var destinationTCCFolder = path.join(simulatorsFolder, simId, 
'/data/Library/TCC');
+if(!util.doesFileExist(destinationTCCFolder)){
+fs.mkdir(destinationTCCFolder, TCC_FOLDER_PERMISSION);
+}
+var command = "cp " + this.tccDbPath + " " + destinationTCCFolder;
+logger.info("Running Command: " + command);
+shelljs.exec(command, {silent: true, async: false});
+}
--- End diff --

The `ncp` module is also an option.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60320027
  
--- Diff: main.js ---
@@ -37,6 +39,30 @@ if (pathToParamedicConfig || // --config
 ParamedicConfig.parseFromFile(pathToParamedicConfig):
 ParamedicConfig.parseFromArguments(argv);
 
+if(argv.plugin) {
+paramedicConfig.setPlugins(argv.plugin);
+}
+
+if(argv.outputDir) {
+paramedicConfig.setOutputDir(argv.outputDir);
+}
+
+if(argv.logMins) {
+paramedicConfig.setLogMins(argv.logMins);
+}
+
+if(argv.tccDbPath){
--- End diff --

Do you assume the tccDbPath exists? Perhaps you validate somewhere else - 
should you instead validate here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60319977
  
--- Diff: main.js ---
@@ -37,6 +39,30 @@ if (pathToParamedicConfig || // --config
 ParamedicConfig.parseFromFile(pathToParamedicConfig):
 ParamedicConfig.parseFromArguments(argv);
 
+if(argv.plugin) {
+paramedicConfig.setPlugins(argv.plugin);
+}
+
+if(argv.outputDir) {
--- End diff --

Do you assume the outputDir exists? Perhaps you validate somewhere else - 
should you instead validate here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60319371
  
--- Diff: lib/ParamediciOSPermissions.js ---
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path = require('path');
+var fs   = require('fs');
+var shelljs  = require("shelljs");
+var logger   = require('./utils').logger;
+var util = require('./utils').utilities;
+
+var TCC_FOLDER_PERMISSION = 0777;
+
+function ParamediciOSPermissions(appName, tccDbPath) {
+this.appName = appName;
+this.tccDbPath = tccDbPath;
+}
+
+ParamediciOSPermissions.prototype.updatePermissions = 
function(serviceList){
+var simulatorsFolder   = util.getSimulatorsFolder();
+var simId  = util.getSimId();
+logger.info('Sim Id is: ' + simId);
+var destinationTCCFile = path.join(simulatorsFolder, simId, 
'/data/Library/TCC/TCC.db');
+
+if(!util.doesFileExist(destinationTCCFile)) {
+// No TCC.db file exists by default. So, Copy the new TCC.db file
+var destinationTCCFolder = path.join(simulatorsFolder, simId, 
'/data/Library/TCC');
+if(!util.doesFileExist(destinationTCCFolder)){
+fs.mkdir(destinationTCCFolder, TCC_FOLDER_PERMISSION);
+}
+var command = "cp " + this.tccDbPath + " " + destinationTCCFolder;
+logger.info("Running Command: " + command);
+shelljs.exec(command, {silent: true, async: false});
+}
--- End diff --

You should consider using shelljs.cp instead?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60319212
  
--- Diff: lib/ParamedicConfig.js ---
@@ -36,8 +36,10 @@ ParamedicConfig.parseFromArguments = function (argv) {
 startPort: argv.startport || argv.port,
 endPort:   argv.endport || argv.port,
 externalServerUrl: argv.externalServerUrl,
-reportSavePath:!!argv.reportSavePath? argv.reportSavePath: 
undefined,
-cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false
+outputDir: !!argv.outputDir? argv.outputDir: null,
+cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false,
+logMins:   !!argv.logMins? argv.logMins: null,
+tccDbPath: !!argv.tccDbPath? argv.tccDbPath: null
--- End diff --

consider renaming tccDbPath to tccDb - it's simpler


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60318605
  
--- Diff: lib/ParamedicConfig.js ---
@@ -36,8 +36,10 @@ ParamedicConfig.parseFromArguments = function (argv) {
 startPort: argv.startport || argv.port,
 endPort:   argv.endport || argv.port,
 externalServerUrl: argv.externalServerUrl,
-reportSavePath:!!argv.reportSavePath? argv.reportSavePath: 
undefined,
-cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false
+outputDir: !!argv.outputDir? argv.outputDir: null,
+cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false,
+logMins:   !!argv.logMins? argv.logMins: null,
--- End diff --

It might be a good idea to initialize defaults for optional parameters here 
e.g. util.DEFAULT_LOG_TIME


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-19 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60307151
  
--- Diff: lib/ParamediciOSPermissions.js ---
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path = require('path');
+var fs   = require('fs');
+var shelljs  = require("shelljs");
+var logger   = require('./utils').logger;
+var util = require('./utils').utilities;
+
+var TCC_FOLDER_PERMISSION = 0777;
--- End diff --

Why doesn't `0644` work? If execution permissions are required on the 
folder, then please use `0755`. Using `0777` is a security hazard.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-18 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r60128184
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
--- End diff --

nitpick: 'dbPath' -> 'tccDbPath'


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-15 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59903675
  
--- Diff: lib/ParamedicLog.js ---
@@ -0,0 +1,154 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+
+"use strict";
+
+var shelljs  = require("shelljs");
+var fs   = require("fs");
+var path = require("path");
+var util = require('./utils').utilities;
+var logger   = require('./utils').logger;
+
+
+function ParamedicLog(platform, appPath, logPath){
+this.platform = platform;
+this.appPath = appPath;
+this.logPath = logPath;
+}
+
+ParamedicLog.prototype.logIOS = function (appPath) {
+// We need to print out the system log for the simulator app. In order 
to figure
+// out the path to that file, we need to find the ID of the simulator 
running
+// mobilespec
+
+// First, figure out the simulator that ran mobilespec. "cordova run"" 
just chooses
--- End diff --

I find this to be very fragile code because it depends on internal 
implementation details of ```cordova run --list```. Those could well change in 
the future. I think it  might be better to just copy the logic that deals with 
listing the simulators in this project.
What do you think ? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread purplecabbage
Github user purplecabbage commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59791877
  
--- Diff: lib/ParamedicKill.js ---
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var shelljs = require("shelljs");
+var util= require("./utils").utilities;
+var logger  = require('./utils').logger;
+
+function ParamedicKill(platform) {
+this.platform = platform;
+}
+
+ParamedicKill.prototype.kill = function() {
+// shell config
+shelljs.config.fatal  = false;
+shelljs.config.silent = false;
+
+// get platform tasks
+var platformTasks = this.tasksOnPlatform(this.platform);
+
+if (platformTasks.length < 1) {
+console.warn("no known tasks to kill");
+}
+
+// kill them
+this.killTasks(platformTasks);
+
+if (this.platform === util.ANDROID) {
+this.killAdbServer();
+}
+
+}
+
+ParamedicKill.prototype.tasksOnPlatform = function (platformName) {
+switch (platformName) {
+case util.WINDOWS:
+return ["WWAHost.exe", "Xde.exe"];
+case util.IOS:
+return ["Simulator"];
+case util.ANDROID:
+if (util.isWindows()) {
+return ["emulator-arm.exe"];
+} else {
+return ["emulator64-x86", "emulator64-arm"];
+}
+break;
--- End diff --

Personally I prefer NOT returning from a switch, and having a break for 
every condition ( or a commented fall through )

```
var retTaskList = [];
switch(platformName) {
  case util.WINDOWS :
  retTaskList = ["WWAHost.exe", "Xde.exe"];
  break;
 ...
} 
return retTaskList;
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread sgrebnov
Github user sgrebnov commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59777381
  
--- Diff: lib/paramedic.js ---
@@ -105,10 +116,23 @@ ParamedicRunner.prototype.checkPlatformRequirements = 
function() {
 logger.normal("cordova-paramedic: checking requirements for platform " 
+ this.config.getPlatformId());
 var result = exec('cordova requirements ' + 
this.config.getPlatformId());
 
-if (result.code !== 0) 
+if (result.code !== 0)
 throw new Error('Platform requirements check has failed!');
 };
 
+ParamedicRunner.prototype.setPermissions = function() {
--- End diff --

Permission logic could be implemented via separate plugin with hooks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread sgrebnov
Github user sgrebnov commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59776906
  
--- Diff: main.js ---
@@ -25,7 +25,12 @@ var USAGE = "Error missing args. \n" +
 "--useTunnel : (optional) use tunneling instead of local address. 
default is false\n" +
 "--config : (optional) read configuration from paramedic configuration 
file\n" +
 "--reportSavePath: (optional) path to save Junit results file\n" +
-"--cleanUpAfterRun: (optional) cleans up the application after the 
run.";
+"--cleanUpAfterRun: (optional) cleans up the application after the 
run\n" +
+"--logPath: (optional) path to store device logs - application path 
will be used by default\n" +
+"--logMins: (optional) Windows only - specifies number of minutes to 
get logs\n" +
+"--appName: (optional) iOS only - specifies the name of the app to be 
deployed\n" +
+"--simulatorsFolder: (optional) iOS only - specifies the path for the 
simulatorsFolder\n" +
+"--tccDbPath: (optional) iOS only - specifies the path for the TCC.db 
file to be copied.";
--- End diff --

Readme.md should be updated as well


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59769584
  
--- Diff: lib/ParamedicKill.js ---
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var shelljs = require("shelljs");
+var util= require("./utils").utilities;
+var logger  = require('./utils').logger;
+
+function ParamedicKill(platform) {
+this.platform = platform;
+}
+
+ParamedicKill.prototype.kill = function() {
+// shell config
+shelljs.config.fatal  = false;
+shelljs.config.silent = false;
+
+// get platform tasks
+var platformTasks = this.tasksOnPlatform(this.platform);
+
+if (platformTasks.length < 1) {
+console.warn("no known tasks to kill");
+}
+
+// kill them
+this.killTasks(platformTasks);
+
+if (this.platform === util.ANDROID) {
+this.killAdbServer();
+}
+
+}
+
+ParamedicKill.prototype.tasksOnPlatform = function (platformName) {
+switch (platformName) {
+case util.WINDOWS:
+return ["WWAHost.exe", "Xde.exe"];
+case util.IOS:
+return ["Simulator"];
+case util.ANDROID:
+if (util.isWindows()) {
+return ["emulator-arm.exe"];
+} else {
+return ["emulator64-x86", "emulator64-arm"];
+}
+break;
--- End diff --

this ```break``` statement will never be reached.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59762195
  
--- Diff: lib/ParamedicKill.js ---
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var shelljs = require("shelljs");
+var util= require("./utils").utilities;
+var logger  = require('./utils').logger;
+
+function ParamedicKill(platform) {
+this.platform = platform;
+}
+
+ParamedicKill.prototype.kill = function() {
+// shell config
+shelljs.config.fatal  = false;
+shelljs.config.silent = false;
+
+// get platform tasks
+var platformTasks = this.tasksOnPlatform(this.platform);
+
+if (platformTasks.length < 1) {
+console.warn("no known tasks to kill");
--- End diff --

in this case, we want to stop processing and bail out of the ```kill``` 
function.
Please, add a ```return``` statement here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread omefire
Github user omefire commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59762070
  
--- Diff: lib/ParamedicKill.js ---
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var shelljs = require("shelljs");
+var util= require("./utils").utilities;
+var logger  = require('./utils').logger;
+
+function ParamedicKill(platform) {
+this.platform = platform;
+}
+
+ParamedicKill.prototype.kill = function() {
+// shell config
+shelljs.config.fatal  = false;
+shelljs.config.silent = false;
+
+// get platform tasks
+var platformTasks = this.tasksOnPlatform(this.platform);
+
+if (platformTasks.length < 1) {
+console.warn("no known tasks to kill");
+}
+
+// kill them
+this.killTasks(platformTasks);
+
+if (this.platform === util.ANDROID) {
+this.killAdbServer();
+}
+
+}
+
+ParamedicKill.prototype.tasksOnPlatform = function (platformName) {
+switch (platformName) {
+case util.WINDOWS:
+return ["WWAHost.exe", "Xde.exe"];
+case util.IOS:
+return ["Simulator"];
--- End diff --

consider returning an empty array if none of the platforms match this list.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-14 Thread rakatyal
Github user rakatyal commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59745115
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
+   var sqlite3Command_secondPart = ' "insert into 
access(service, client, client_type, allowed, prompt_count, csreq) values(\'';
+   var sqlite3Command_lastPart   = '\',\'' + self.appName 
+ '\',0,1,1,NULL)"';
+   serviceList.forEach(function(service){
+   var command = sqlite3Command_firstPart  +  
sqlite3Command_secondPart + service + sqlite3Command_lastPart ;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: 
false});
+   });
+   } else {
+   // No TCC.db file exists by default. So, Copy the new 
TCC.db file
+   var destinationTCCFolder = 
path.join(self.simulatorsFolder, simFolder, '/data/Library/TCC');
+   if(!self.doesFileExist(destinationTCCFolder)){
+   fs.mkdir(destinationTCCFolder, 0777);
+   }
+   var command = "cp " + self.dbPath + " " + 
destinationTCCFolder;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: false});
+   }
+   });
+}
+
+ParamedicPermissions.prototype.getDirectories = function(srcpath) {
--- End diff --

Consider renaming it srcPath.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59646081
  
--- Diff: lib/paramedic.js ---
@@ -210,13 +234,29 @@ ParamedicRunner.prototype.waitForConnection = 
function() {
 };
 
 ParamedicRunner.prototype.cleanUpProject = function() {
-if(this.config.getShouldCleanUpAfterRun()) {
+if(this.config.shouldCleanUpAfterRun()) {
 logger.info("cordova-paramedic: Deleting the application: " + 
this.tempFolder.name);
 shell.popd();
 shell.rm('-rf', this.tempFolder.name);
 }
 };
 
+ParamedicRunner.prototype.killProcess = function() {
+if(this.config.shouldCleanUpAfterRun()){
+logger.info("cordova-paramedic: Killing the process.");
--- End diff --

emulator process?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59645814
  
--- Diff: lib/ParamedicLog.js ---
@@ -0,0 +1,154 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+
+"use strict";
+
+var shelljs  = require("shelljs");
+var fs   = require("fs");
+var path = require("path");
+var util = require('./utils').utilities;
+var logger   = require('./utils').logger;
+
+
+function ParamedicLog(platform, appPath, logPath){
+this.platform = platform;
+this.appPath = appPath;
+this.logPath = logPath;
+}
+
+ParamedicLog.prototype.logIOS = function (appPath) {
+// We need to print out the system log for the simulator app. In order 
to figure
+// out the path to that file, we need to find the ID of the simulator 
running
+// mobilespec
+
+// First, figure out the simulator that ran mobilespec. "cordova run"" 
just chooses
+// the last simulator in this list that starts with the word "iPhone"
+shelljs.pushd(appPath);
+
+var findSimCommand = this.getLocalCLI() + " run --list --emulator | 
grep ^iPhone | tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+if (simId) {
+// Now we can print out the log file
+var logPath = path.join("~", "Library", "Logs", "CoreSimulator", 
simId, "system.log");
+var logCommand = "cat " + logPath;
+this.generateLogs(logCommand);
+} else {
+logger.error("Failed to find ID of mobilespec simulator");
+}
+}
+
+ParamedicLog.prototype.logWindows = function (appPath, logMins) {
+var logScriptPath = path.join(appPath, "platforms", "windows", 
"cordova", "log.bat");
+if (fs.existsSync(logScriptPath)) {
+var mins = util.DEFAULT_LOG_TIME;
+if (logMins) {
+mins = logMins + util.DEFAULT_LOG_TIME_ADDITIONAL;
+}
+var logCommand = logScriptPath + " --dump --mins " + mins;
+this.generateLogs(logCommand);
+}
+}
+
+ParamedicLog.prototype.logAndroid = function (){
+var logCommand = "adb logcat -d";
+
+var numDevices = util.countAndroidDevices();
+if (numDevices != 1) {
+logger.error("there must be exactly one emulator/device attached");
+return;
+}
+this.generateLogs(logCommand);
+}
+
+ParamedicLog.prototype.generateLogs = function(logCommand) {
+var logFile = this.getLogFileName();
+logger.info('Running Command: ' + logCommand);
+
+var result = shelljs.exec(logCommand, {silent: true, async: false});
+if (result.code > 0) {
+logger.error("Failed to run command: " + logCommand);
+return;
+}
+
+try {
+fs.writeFileSync(logFile, result.output);
+} catch (ex) {
+logger.error("Cannot write the log results to the file. " + ex);
+}
+}
+
+ParamedicLog.prototype.getLogFileName = function() {
+return path.join(this.logPath, this.platform+"_logs.txt");
--- End diff --

spaces missing


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled a

[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59645737
  
--- Diff: lib/ParamedicLog.js ---
@@ -0,0 +1,154 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+
+"use strict";
+
+var shelljs  = require("shelljs");
+var fs   = require("fs");
+var path = require("path");
+var util = require('./utils').utilities;
+var logger   = require('./utils').logger;
+
+
+function ParamedicLog(platform, appPath, logPath){
+this.platform = platform;
+this.appPath = appPath;
+this.logPath = logPath;
+}
+
+ParamedicLog.prototype.logIOS = function (appPath) {
+// We need to print out the system log for the simulator app. In order 
to figure
+// out the path to that file, we need to find the ID of the simulator 
running
+// mobilespec
+
+// First, figure out the simulator that ran mobilespec. "cordova run"" 
just chooses
+// the last simulator in this list that starts with the word "iPhone"
+shelljs.pushd(appPath);
+
+var findSimCommand = this.getLocalCLI() + " run --list --emulator | 
grep ^iPhone | tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+if (simId) {
+// Now we can print out the log file
+var logPath = path.join("~", "Library", "Logs", "CoreSimulator", 
simId, "system.log");
+var logCommand = "cat " + logPath;
+this.generateLogs(logCommand);
+} else {
+logger.error("Failed to find ID of mobilespec simulator");
+}
+}
+
+ParamedicLog.prototype.logWindows = function (appPath, logMins) {
+var logScriptPath = path.join(appPath, "platforms", "windows", 
"cordova", "log.bat");
+if (fs.existsSync(logScriptPath)) {
+var mins = util.DEFAULT_LOG_TIME;
+if (logMins) {
+mins = logMins + util.DEFAULT_LOG_TIME_ADDITIONAL;
+}
+var logCommand = logScriptPath + " --dump --mins " + mins;
+this.generateLogs(logCommand);
+}
+}
+
+ParamedicLog.prototype.logAndroid = function (){
+var logCommand = "adb logcat -d";
+
+var numDevices = util.countAndroidDevices();
+if (numDevices != 1) {
+logger.error("there must be exactly one emulator/device attached");
+return;
+}
+this.generateLogs(logCommand);
+}
+
+ParamedicLog.prototype.generateLogs = function(logCommand) {
+var logFile = this.getLogFileName();
+logger.info('Running Command: ' + logCommand);
+
+var result = shelljs.exec(logCommand, {silent: true, async: false});
+if (result.code > 0) {
+logger.error("Failed to run command: " + logCommand);
+return;
+}
+
+try {
+fs.writeFileSync(logFile, result.output);
+} catch (ex) {
+logger.error("Cannot write the log results to the file. " + ex);
+}
+}
+
+ParamedicLog.prototype.getLogFileName = function() {
+return path.join(this.logPath, this.platform+"_logs.txt");
+}
+
+ParamedicLog.prototype.getLocalCLI = function (){
--- End diff --

Consider just using "cordova" inline instead of this method.


---
If your project is set up for it, you can repl

[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59645230
  
--- Diff: lib/ParamedicLog.js ---
@@ -0,0 +1,154 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+
+"use strict";
+
+var shelljs  = require("shelljs");
+var fs   = require("fs");
+var path = require("path");
+var util = require('./utils').utilities;
+var logger   = require('./utils').logger;
+
+
+function ParamedicLog(platform, appPath, logPath){
+this.platform = platform;
+this.appPath = appPath;
+this.logPath = logPath;
+}
+
+ParamedicLog.prototype.logIOS = function (appPath) {
+// We need to print out the system log for the simulator app. In order 
to figure
+// out the path to that file, we need to find the ID of the simulator 
running
+// mobilespec
+
+// First, figure out the simulator that ran mobilespec. "cordova run"" 
just chooses
+// the last simulator in this list that starts with the word "iPhone"
+shelljs.pushd(appPath);
+
+var findSimCommand = this.getLocalCLI() + " run --list --emulator | 
grep ^iPhone | tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+if (simId) {
+// Now we can print out the log file
+var logPath = path.join("~", "Library", "Logs", "CoreSimulator", 
simId, "system.log");
+var logCommand = "cat " + logPath;
+this.generateLogs(logCommand);
+} else {
+logger.error("Failed to find ID of mobilespec simulator");
+}
+}
+
+ParamedicLog.prototype.logWindows = function (appPath, logMins) {
+var logScriptPath = path.join(appPath, "platforms", "windows", 
"cordova", "log.bat");
+if (fs.existsSync(logScriptPath)) {
+var mins = util.DEFAULT_LOG_TIME;
+if (logMins) {
+mins = logMins + util.DEFAULT_LOG_TIME_ADDITIONAL;
+}
+var logCommand = logScriptPath + " --dump --mins " + mins;
+this.generateLogs(logCommand);
+}
+}
+
+ParamedicLog.prototype.logAndroid = function (){
+var logCommand = "adb logcat -d";
+
+var numDevices = util.countAndroidDevices();
+if (numDevices != 1) {
+logger.error("there must be exactly one emulator/device attached");
+return;
+}
+this.generateLogs(logCommand);
+}
+
+ParamedicLog.prototype.generateLogs = function(logCommand) {
+var logFile = this.getLogFileName();
+logger.info('Running Command: ' + logCommand);
+
+var result = shelljs.exec(logCommand, {silent: true, async: false});
+if (result.code > 0) {
+logger.error("Failed to run command: " + logCommand);
--- End diff --

Ideally you want to log return code and stderr/stdout


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: d

[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59644970
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
+   var sqlite3Command_secondPart = ' "insert into 
access(service, client, client_type, allowed, prompt_count, csreq) values(\'';
+   var sqlite3Command_lastPart   = '\',\'' + self.appName 
+ '\',0,1,1,NULL)"';
+   serviceList.forEach(function(service){
+   var command = sqlite3Command_firstPart  +  
sqlite3Command_secondPart + service + sqlite3Command_lastPart ;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: 
false});
+   });
+   } else {
+   // No TCC.db file exists by default. So, Copy the new 
TCC.db file
+   var destinationTCCFolder = 
path.join(self.simulatorsFolder, simFolder, '/data/Library/TCC');
+   if(!self.doesFileExist(destinationTCCFolder)){
+   fs.mkdir(destinationTCCFolder, 0777);
+   }
+   var command = "cp " + self.dbPath + " " + 
destinationTCCFolder;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: false});
--- End diff --

Consider writing a comment of why you are not handling errors here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59644686
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
+   var sqlite3Command_secondPart = ' "insert into 
access(service, client, client_type, allowed, prompt_count, csreq) values(\'';
+   var sqlite3Command_lastPart   = '\',\'' + self.appName 
+ '\',0,1,1,NULL)"';
+   serviceList.forEach(function(service){
+   var command = sqlite3Command_firstPart  +  
sqlite3Command_secondPart + service + sqlite3Command_lastPart ;
--- End diff --

Consider using `util.format`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59644267
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
+   var sqlite3Command_secondPart = ' "insert into 
access(service, client, client_type, allowed, prompt_count, csreq) values(\'';
--- End diff --

Instead of copying a tcc db with permissions - consider copying empty and 
insert permissions into it - that helps in configuring permissions only in one 
place.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59644069
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
+   var sqlite3Command_secondPart = ' "insert into 
access(service, client, client_type, allowed, prompt_count, csreq) values(\'';
+   var sqlite3Command_lastPart   = '\',\'' + self.appName 
+ '\',0,1,1,NULL)"';
+   serviceList.forEach(function(service){
+   var command = sqlite3Command_firstPart  +  
sqlite3Command_secondPart + service + sqlite3Command_lastPart ;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: 
false});
+   });
+   } else {
+   // No TCC.db file exists by default. So, Copy the new 
TCC.db file
+   var destinationTCCFolder = 
path.join(self.simulatorsFolder, simFolder, '/data/Library/TCC');
+   if(!self.doesFileExist(destinationTCCFolder)){
+   fs.mkdir(destinationTCCFolder, 0777);
+   }
+   var command = "cp " + self.dbPath + " " + 
destinationTCCFolder;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: false});
+   }
+   });
+}
+
+ParamedicPermissions.prototype.getDirectories = function(srcpath) {
+   return fs.readdirSync(srcpath).filter(function(file) {
+   return fs.statSync(path.join(srcpath, file)).isDirectory();
+   });
+}
+
+ParamedicPermissions.prototype.doesFileExist = function(filePath) {
+   var fileExists = false;
--- End diff --

consider factoring it out into `util` module


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59643631
  
--- Diff: lib/ParamedicConfig.js ---
@@ -104,4 +117,44 @@ ParamedicConfig.prototype.getTimeout = function() {
 return DEFAULT_TIMEOUT;
 };
 
+ParamedicConfig.prototype.getLogPath = function() {
+return this._config.logPath;
+};
+
+ParamedicConfig.prototype.setLogPath = function(logPath) {
+this._config.logPath = logPath;
+};
+
+ParamedicConfig.prototype.getLogMins = function() {
+return this._config.logMins;
+};
+
+ParamedicConfig.prototype.setLogMins = function(logMins) {
+this._config.logMins = logMins;
+};
+
+ParamedicConfig.prototype.setAppName = function(appName) {
+this._config.appName = appName;
+};
+
+ParamedicConfig.prototype.getAppName = function() {
+return this._config.appName;
+};
+
+ParamedicConfig.prototype.setSimulatorsFolder = function(simulatorsFolder) 
{
+this._config.simulatorsFolder = simulatorsFolder;
--- End diff --

Consider using what we do for getting simulator logs. Ideally we should 
have one way of doing this and not configurable externally.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59642669
  
--- Diff: lib/ParamedicConfig.js ---
@@ -104,4 +117,44 @@ ParamedicConfig.prototype.getTimeout = function() {
 return DEFAULT_TIMEOUT;
 };
 
+ParamedicConfig.prototype.getLogPath = function() {
+return this._config.logPath;
+};
+
+ParamedicConfig.prototype.setLogPath = function(logPath) {
+this._config.logPath = logPath;
+};
+
+ParamedicConfig.prototype.getLogMins = function() {
+return this._config.logMins;
+};
+
+ParamedicConfig.prototype.setLogMins = function(logMins) {
+this._config.logMins = logMins;
+};
+
+ParamedicConfig.prototype.setAppName = function(appName) {
+this._config.appName = appName;
--- End diff --

Either remove this config parameter & use a default value that you can 
assume to be true 
or create the app with the name specified here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59641603
  
--- Diff: lib/ParamedicConfig.js ---
@@ -104,4 +117,44 @@ ParamedicConfig.prototype.getTimeout = function() {
 return DEFAULT_TIMEOUT;
 };
 
+ParamedicConfig.prototype.getLogPath = function() {
+return this._config.logPath;
+};
+
+ParamedicConfig.prototype.setLogPath = function(logPath) {
+this._config.logPath = logPath;
--- End diff --

Consider re-using `outputDir`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59641411
  
--- Diff: lib/ParamedicConfig.js ---
@@ -53,7 +58,11 @@ ParamedicConfig.prototype.getReportSavePath = function 
() {
 return this._config.reportSavePath;
 };
 
-ParamedicConfig.prototype.getShouldCleanUpAfterRun = function () {
+ParamedicConfig.prototype.setReportSavePath = function (reportSavePath) {
+this._config.reportSavePath = reportSavePath;
--- End diff --

Consider renaming this to `testResultsPath` or `testResultsDir` or 
`outputDir`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59639808
  
--- Diff: lib/ParamedicLog.js ---
@@ -0,0 +1,154 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+
+"use strict";
+
+var shelljs  = require("shelljs");
+var fs   = require("fs");
+var path = require("path");
+var util = require('./utils').utilities;
+var logger   = require('./utils').logger;
+
+
+function ParamedicLog(platform, appPath, logPath){
+this.platform = platform;
+this.appPath = appPath;
+this.logPath = logPath;
+}
+
+ParamedicLog.prototype.logIOS = function (appPath) {
+// We need to print out the system log for the simulator app. In order 
to figure
+// out the path to that file, we need to find the ID of the simulator 
running
+// mobilespec
+
+// First, figure out the simulator that ran mobilespec. "cordova run"" 
just chooses
+// the last simulator in this list that starts with the word "iPhone"
+shelljs.pushd(appPath);
+
+var findSimCommand = this.getLocalCLI() + " run --list --emulator | 
grep ^iPhone | tail -n1";
+
+logger.info("running:");
+logger.info("" + findSimCommand);
+
+var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: 
false});
+
+if (findSimResult.code > 0) {
+logger.error("Failed to find simulator we deployed to");
+return;
+}
+
+var split = findSimResult.output.split(", ");
+
+// Format of the output is "iPhone-6s-Plus, 9.1"
+// Extract the device name and the version number
+var device = split[0].replace(/-/g, " ").trim();
+var version = split[1].trim();
+
+// Next, figure out the ID of the simulator we found
+var instrCommand = "instruments -s devices | grep ^iPhone";
+logger.info("running:");
+logger.info("" + instrCommand);
+
+var instrResult = shelljs.exec(instrCommand, {silent: true, async: 
false});
+
+if (instrResult.code > 0) {
+logger.error("Failed to get the list of simulators");
+return;
+}
+
+// This matches  () []
+var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\]$/;
+
+var simId = null;
+var lines = instrResult.output.split(/\n/);
+lines.forEach(function(line) {
+var simIdMatch = simIdRegex.exec(line);
+if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === 
device && simIdMatch[2] === version) {
+simId = encodeURIComponent(simIdMatch[3]);
+}
+});
+
+if (simId) {
+// Now we can print out the log file
+var logPath = path.join("~", "Library", "Logs", "CoreSimulator", 
simId, "system.log");
+var logCommand = "cat " + logPath;
+this.generateLogs(logCommand);
+} else {
+logger.error("Failed to find ID of mobilespec simulator");
+}
+}
+
+ParamedicLog.prototype.logWindows = function (appPath, logMins) {
+var logScriptPath = path.join(appPath, "platforms", "windows", 
"cordova", "log.bat");
+if (fs.existsSync(logScriptPath)) {
+var mins = util.DEFAULT_LOG_TIME;
+if (logMins) {
+mins = logMins + util.DEFAULT_LOG_TIME_ADDITIONAL;
+}
+var logCommand = logScriptPath + " --dump --mins " + mins;
+this.generateLogs(logCommand);
+}
+}
+
+ParamedicLog.prototype.logAndroid = function (){
+var logCommand = "adb logcat -d";
--- End diff --

Please use "adb logcat -d -v time"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59638892
  
--- Diff: lib/paramedic.js ---
@@ -105,10 +116,23 @@ ParamedicRunner.prototype.checkPlatformRequirements = 
function() {
 logger.normal("cordova-paramedic: checking requirements for platform " 
+ this.config.getPlatformId());
 var result = exec('cordova requirements ' + 
this.config.getPlatformId());
 
-if (result.code !== 0) 
+if (result.code !== 0)
 throw new Error('Platform requirements check has failed!');
 };
 
+ParamedicRunner.prototype.setPermissions = function() {
+if(this.config.getPlatformId() === 'ios'){
--- End diff --

Does this function only support iOS?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59634307
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
+   var sqlite3Command_secondPart = ' "insert into 
access(service, client, client_type, allowed, prompt_count, csreq) values(\'';
+   var sqlite3Command_lastPart   = '\',\'' + self.appName 
+ '\',0,1,1,NULL)"';
+   serviceList.forEach(function(service){
+   var command = sqlite3Command_firstPart  +  
sqlite3Command_secondPart + service + sqlite3Command_lastPart ;
+   logger.info("Running Command: " + command);
+   shelljs.exec(command, {silent: true, async: 
false});
+   });
+   } else {
+   // No TCC.db file exists by default. So, Copy the new 
TCC.db file
+   var destinationTCCFolder = 
path.join(self.simulatorsFolder, simFolder, '/data/Library/TCC');
+   if(!self.doesFileExist(destinationTCCFolder)){
+   fs.mkdir(destinationTCCFolder, 0777);
--- End diff --

Please use 0644 instead of 0777 here. Also, please factor out the 
permissions setting into a variable.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59633776
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
--- End diff --

If a regular for-loop is used here, the `self` pattern can be avoided.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59633588
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
--- End diff --

Nitpick: spacing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59633116
  
--- Diff: lib/ParamedicKill.js ---
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var shelljs = require("shelljs");
+var util= require("./utils").utilities;
+var logger  = require('./utils').logger;
+
+function ParamedicKill(platform) {
+this.platform = platform;
+}
+
+ParamedicKill.prototype.kill = function() {
+// shell config
+shelljs.config.fatal  = false;
+shelljs.config.silent = false;
+
+// get platform tasks
+var platformTasks = this.tasksOnPlatform(this.platform);
+
+if (platformTasks.length < 1) {
+console.warn("no known tasks to kill");
+}
+
+// kill them
+this.killTasks(platformTasks);
+
+if (this.platform === util.ANDROID) {
+this.killAdbServer();
+}
+
+}
+
+ParamedicKill.prototype.tasksOnPlatform = function (platformName) {
+switch (platformName) {
+case util.WINDOWS:
+return ["WWAHost.exe", "Xde.exe"];
+case util.IOS:
+return ["Simulator"];
--- End diff --

Please add `"iOS Simulator"` to this array.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread dblotsky
Github user dblotsky commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59632979
  
--- Diff: lib/ParamedicConfig.js ---
@@ -37,7 +37,12 @@ ParamedicConfig.parseFromArguments = function (argv) {
 endPort:   argv.endport || argv.port,
 externalServerUrl: argv.externalServerUrl,
 reportSavePath:!!argv.reportSavePath? argv.reportSavePath: 
undefined,
-cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false
+cleanUpAfterRun:   !!argv.cleanUpAfterRun? true: false,
+logPath:   !!argv.logPath? argv.logPath: undefined,
+logMins:   !!argv.logMins? argv.logMins: undefined,
+appName:   !!argv.appName? argv.appName: undefined,
+simulatorsFolder:  !!argv.simulatorsFolder? argv.simulatorsFolder: 
undefined,
+tccDbPath: !!argv.tccDbPath? argv.tccDbPath: undefined
--- End diff --

Please add defaults for these properties, or set them to `null` instead of 
`undefined`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread riknoll
Github user riknoll commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59631368
  
--- Diff: lib/paramedic.js ---
@@ -17,22 +17,30 @@
 under the License.
 */
 
-var exec = require('./utils').exec,
-shell = require('shelljs'),
-Server = require('./LocalServer'),
-Q = require('q'),
-tmp = require('tmp'),
-PluginsManager = require('./PluginsManager'),
-path = require('path'),
-Q = require('q'),
-fs = require('fs'),
-getReporters = require('./Reporters'),
-logger = require('./utils').logger;
+var exec= require('./utils').exec;
+var shell   = require('shelljs');
+var Server  = require('./LocalServer');
+var Q   = require('q');
+var tmp = require('tmp');
+var path= require('path');
+var Q   = require('q');
--- End diff --

Q is being required twice


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-paramedic pull request: Code changes for Collecting Device...

2016-04-13 Thread riknoll
Github user riknoll commented on a diff in the pull request:

https://github.com/apache/cordova-paramedic/pull/4#discussion_r59630497
  
--- Diff: lib/ParamedicPermissions.js ---
@@ -0,0 +1,60 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+var path= require('path');
+var fs  = require('fs');
+var shelljs  = require("shelljs");
+var logger  = require('./utils').logger;
+
+function ParamedicPermissions(appName, simulatorsFolder, dbPath) {
+   this.appName = appName;
+   this.simulatorsFolder = simulatorsFolder;
+   this.dbPath = dbPath;
+}
+
+ParamedicPermissions.prototype.updatePermissions = function(serviceList){
+   var self = this;
+   this.getDirectories(self.simulatorsFolder).forEach(function(simFolder){
+   var destinationTCCFile = path.join(self.simulatorsFolder, 
simFolder, '/data/Library/TCC/TCC.db');
+
+   //Check if the simFolder has TCC.db file in it
+   if(self.doesFileExist(destinationTCCFile)) {
+   var sqlite3Command_firstPart  = 'sqlite3 ' + 
destinationTCCFile;
--- End diff --

Why split this variable into three parts like this?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org