Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobile-cli-lib

Package Overview
Dependencies
Maintainers
8
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobile-cli-lib - npm Package Compare versions

Comparing version 0.17.2 to 0.17.3

services/net-service.js

1

bootstrap.js

@@ -97,1 +97,2 @@ global._ = require("lodash");

$injector.require("xcodeSelectService", "./services/xcode-select-service");
$injector.require("net", "./services/net-service");

86

mobile/mobile-core/android-process-service.js

@@ -6,3 +6,3 @@ "use strict";

var AndroidProcessService = (function () {
function AndroidProcessService($errors, $staticConfig, $injector, $httpClient) {
function AndroidProcessService($errors, $staticConfig, $injector, $httpClient, $net) {
this.$errors = $errors;

@@ -12,2 +12,3 @@ this.$staticConfig = $staticConfig;

this.$httpClient = $httpClient;
this.$net = $net;
this._devicesAdbs = {};

@@ -39,9 +40,8 @@ }

}
var availablePorts = _this.getAvailableAndroidPortsInformation(adb, appIdentifier).wait();
if (!availablePorts || !availablePorts.length) {
_this.$errors.failWithoutHelp("There are no available ports.");
var localPort = _this.getAlreadyMappedPort(adb, deviceIdentifier, abstractPort).wait();
if (!localPort) {
localPort = _this.$net.getFreePort().wait();
adb.executeCommand(["forward", ("tcp:" + localPort), ("localabstract:" + abstractPort)]).wait();
}
var realPort = availablePorts[0];
adb.executeCommand(["forward", ("tcp:" + realPort.number), ("localabstract:" + abstractPort)]).wait();
return realPort.number;
return localPort;
}).future()();

@@ -54,5 +54,7 @@ };

var androidWebViewPortInformation = _this.getAbstractPortsInformation(adb).wait().split(os_1.EOL);
return androidWebViewPortInformation
return _(androidWebViewPortInformation)
.map(function (line) { return _this.getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, line).wait(); })
.filter(function (appIdentifier) { return !!appIdentifier; });
.filter(function (appIdentifier) { return !!appIdentifier; })
.uniqBy("appIdentifier")
.value();
}).future()();

@@ -115,53 +117,17 @@ };

AndroidProcessService.prototype.getProcessId = function (adb, appIdentifier) {
var _this = this;
return (function () {
var processIdRegExp = /^\w*\s*(\d+)/;
var processIdInformation = adb.executeShellCommand(["ps", "|grep", appIdentifier]).wait();
var matches = processIdRegExp.exec(processIdInformation);
if (!matches || !matches[0]) {
return null;
}
return matches[1];
var processIdRegExp = new RegExp("^\\w*\\s*(\\d+).*?" + appIdentifier + "$");
var processIdInformation = adb.executeShellCommand(["ps"]).wait();
return _this.parseMultilineResult(processIdInformation, processIdRegExp);
}).future()();
};
AndroidProcessService.prototype.getAvailableAndroidPortsInformation = function (adb, appIdentifier) {
AndroidProcessService.prototype.getAlreadyMappedPort = function (adb, deviceIdentifier, abstractPort) {
var _this = this;
return (function () {
var tcpPorts = adb.executeShellCommand(["cat", "proc/net/tcp"]).wait().split(os_1.EOL);
var tcp6Ports = adb.executeShellCommand(["cat", "proc/net/tcp6"]).wait().split(os_1.EOL);
var allPorts = tcpPorts.concat(tcp6Ports);
var emptyAddressRegExp = /^00*/;
var localHostHexRegExp = /^00*100007F/;
var localHostVersionSixHexRegExp = /^00*FFFF00000100007F/;
var availablePorts = _(allPorts)
.filter(function (line) { return line.match(_this.androidPortInformationRegExp); })
.map(function (line) { return _this.parseAndroidPortInformation(line); })
.filter(function (port) {
return port.remAddress.match(emptyAddressRegExp) &&
(port.ipAddressHex.match(localHostHexRegExp) ||
port.ipAddressHex.match(localHostVersionSixHexRegExp) ||
port.ipAddressHex.match(emptyAddressRegExp));
})
.value();
return availablePorts;
var allForwardedPorts = adb.executeCommand(["forward", "--list"]).wait() || "";
var regex = new RegExp(deviceIdentifier + "\\s+?tcp:(\\d+?)\\s+?.*?" + abstractPort + ".*$");
return _this.parseMultilineResult(allForwardedPorts, regex);
}).future()();
};
AndroidProcessService.prototype.parseAndroidPortInformation = function (portInformationRow) {
var matches = this.androidPortInformationRegExp.exec(portInformationRow);
if (!matches || !matches[0]) {
return null;
}
var localAddress = matches[2];
var localAddressParts = localAddress.split(":");
var hexIpAddress = localAddressParts[0];
var hexPort = localAddressParts[1];
var portInformation = {
localAddress: localAddress,
remAddress: matches[3],
uid: parseInt(matches[4]),
ipAddressHex: hexIpAddress,
number: parseInt(hexPort, 16),
numberHex: hexPort
};
return portInformation;
};
AndroidProcessService.prototype.getAdb = function (deviceIdentifier) {

@@ -173,2 +139,16 @@ if (!this._devicesAdbs[deviceIdentifier]) {

};
AndroidProcessService.prototype.parseMultilineResult = function (input, regex) {
var selectedNumber;
_((input || "").split('\n'))
.map(function (line) { return line.trim(); })
.filter(function (line) { return !!line; })
.each(function (line) {
var matches = line.match(regex);
if (matches && matches[1]) {
selectedNumber = +matches[1];
return false;
}
});
return selectedNumber;
};
return AndroidProcessService;

@@ -175,0 +155,0 @@ }());

{
"name": "mobile-cli-lib",
"preferGlobal": false,
"version": "0.17.2",
"version": "0.17.3",
"author": "Telerik <support@telerik.com>",

@@ -94,3 +94,3 @@ "description": "common lib used by different CLI",

},
"buildVersion": "211"
"buildVersion": "215"
}

@@ -10,5 +10,5 @@ mobile-cli-lib

Latest version: 0.17.2
Latest version: 0.17.3
Release date: 2016, July 11
Release date: 2016, July 12

@@ -15,0 +15,0 @@ ### System Requirements

@@ -28,3 +28,4 @@ "use strict";

this.showFullLiveSyncInformation = false;
this.batch = null;
this.batch = Object.create(null);
this.livesyncData = Object.create(null);
this.fileHashes = Object.create(null);

@@ -111,3 +112,4 @@ }

var _this = this;
if (!this.batch || !this.batch.syncPending) {
var platformBatch = this.batch[data.platform];
if (!platformBatch || !platformBatch.syncPending) {
var done = function () {

@@ -119,9 +121,13 @@ return (function () {

try {
_this.batch.syncFiles((function (filesToSync) {
for (var _i = 0, filesToSync_1 = filesToSync; _i < filesToSync_1.length; _i++) {
var fileInfo = filesToSync_1[_i];
_this.$liveSyncProvider.preparePlatformForSync(fileInfo.data.platform).wait();
_this.syncCore([fileInfo.data], [fileInfo.filePath]);
}
}).future());
var _loop_1 = function(platformName) {
var batch = _this.batch[platformName];
var livesyncData = _this.livesyncData[platformName];
batch.syncFiles((function (filesToSync) {
_this.$liveSyncProvider.preparePlatformForSync(platformName).wait();
_this.syncCore([livesyncData], filesToSync);
}).future()).wait();
};
for (var platformName in _this.batch) {
_loop_1(platformName);
}
}

@@ -136,5 +142,6 @@ catch (err) {

};
this.batch = this.$injector.resolve(syncBatchLib.SyncBatch, { done: done });
this.batch[data.platform] = this.$injector.resolve(syncBatchLib.SyncBatch, { done: done });
this.livesyncData[data.platform] = data;
}
this.batch.addFile({ data: data, filePath: filePath });
this.batch[data.platform].addFile(filePath);
};

@@ -141,0 +148,0 @@ LiveSyncServiceBase.prototype.syncRemovedFile = function (data, filePath) {

@@ -16,3 +16,3 @@ "use strict";

var _this = this;
var filteredFiles = this.syncQueue.filter(function (syncFile) { return !_this.$projectFilesManager.isFileExcluded(syncFile.filePath); });
var filteredFiles = this.syncQueue.filter(function (syncFile) { return !_this.$projectFilesManager.isFileExcluded(syncFile); });
return filteredFiles;

@@ -19,0 +19,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc