mobile-cli-lib
Version:
common lib used by different CLI
104 lines (103 loc) • 5.1 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var application_manager_base_1 = require("../../application-manager-base");
var Future = require("fibers/future");
var path = require("path");
var temp = require("temp");
var IOSSimulatorApplicationManager = (function (_super) {
__extends(IOSSimulatorApplicationManager, _super);
function IOSSimulatorApplicationManager(iosSim, identifier, $options, $fs, $bplistParser, $iOSSimulatorLogProvider, $deviceLogProvider, $logger) {
_super.call(this, $logger);
this.iosSim = iosSim;
this.identifier = identifier;
this.$options = $options;
this.$fs = $fs;
this.$bplistParser = $bplistParser;
this.$iOSSimulatorLogProvider = $iOSSimulatorLogProvider;
this.$deviceLogProvider = $deviceLogProvider;
}
IOSSimulatorApplicationManager.prototype.getInstalledApplications = function () {
return Future.fromResult(this.iosSim.getInstalledApplications(this.identifier));
};
IOSSimulatorApplicationManager.prototype.installApplication = function (packageFilePath) {
var _this = this;
return (function () {
if (_this.$fs.exists(packageFilePath).wait() && path.extname(packageFilePath) === ".zip") {
temp.track();
var dir = temp.mkdirSync("simulatorPackage");
_this.$fs.unzip(packageFilePath, dir).wait();
var app = _.find(_this.$fs.readDirectory(dir).wait(), function (directory) { return path.extname(directory) === ".app"; });
if (app) {
packageFilePath = path.join(dir, app);
}
}
_this.iosSim.installApplication(_this.identifier, packageFilePath).wait();
}).future()();
};
IOSSimulatorApplicationManager.prototype.uninstallApplication = function (appIdentifier) {
return this.iosSim.uninstallApplication(this.identifier, appIdentifier);
};
IOSSimulatorApplicationManager.prototype.startApplication = function (appIdentifier) {
var _this = this;
return (function () {
var launchResult = _this.iosSim.startApplication(_this.identifier, appIdentifier).wait();
if (!_this.$options.justlaunch) {
var pid = launchResult.split(":")[1].trim();
_this.$deviceLogProvider.setApplictionPidForDevice(_this.identifier, pid);
_this.$iOSSimulatorLogProvider.startLogProcess(_this.identifier);
}
}).future()();
};
IOSSimulatorApplicationManager.prototype.stopApplication = function (cfBundleExecutable) {
return this.iosSim.stopApplication(this.identifier, cfBundleExecutable);
};
IOSSimulatorApplicationManager.prototype.canStartApplication = function () {
return true;
};
IOSSimulatorApplicationManager.prototype.getApplicationInfo = function (applicationIdentifier) {
var _this = this;
return (function () {
var result = null, plistContent = _this.getParsedPlistContent(applicationIdentifier).wait();
if (plistContent) {
result = {
applicationIdentifier: applicationIdentifier,
deviceIdentifier: _this.identifier,
configuration: plistContent && plistContent.configuration
};
}
return result;
}).future()();
};
IOSSimulatorApplicationManager.prototype.isLiveSyncSupported = function (appIdentifier) {
var _this = this;
return (function () {
var plistContent = _this.getParsedPlistContent(appIdentifier).wait();
if (plistContent) {
return !!plistContent && !!plistContent.IceniumLiveSyncEnabled;
}
return false;
}).future()();
};
IOSSimulatorApplicationManager.prototype.getParsedPlistContent = function (appIdentifier) {
var _this = this;
return (function () {
if (!_this.isApplicationInstalled(appIdentifier).wait()) {
return null;
}
var applicationPath = _this.iosSim.getApplicationPath(_this.identifier, appIdentifier), pathToInfoPlist = path.join(applicationPath, "Info.plist");
return _this.$fs.exists(pathToInfoPlist).wait() ? _this.$bplistParser.parseFile(pathToInfoPlist).wait()[0] : null;
}).future()();
};
IOSSimulatorApplicationManager.prototype.getDebuggableApps = function () {
return Future.fromResult([]);
};
IOSSimulatorApplicationManager.prototype.getDebuggableAppViews = function (appIdentifiers) {
return Future.fromResult(null);
};
return IOSSimulatorApplicationManager;
}(application_manager_base_1.ApplicationManagerBase));
exports.IOSSimulatorApplicationManager = IOSSimulatorApplicationManager;