mobile-cli-lib
Advanced tools
Comparing version 0.20.0 to 0.21.0
@@ -14,1 +14,2 @@ require("../bootstrap"); | ||
$injector.requirePublic("npmService", "./appbuilder/services/npm-service"); | ||
$injector.require("iOSLogFilter", "./appbuilder/mobile/ios/ios-log-filter"); |
@@ -7,16 +7,12 @@ "use strict"; | ||
}; | ||
var events_1 = require("events"); | ||
var device_log_provider_base_1 = require("../mobile/device-log-provider-base"); | ||
var DeviceLogProvider = (function (_super) { | ||
__extends(DeviceLogProvider, _super); | ||
function DeviceLogProvider($logFilter) { | ||
_super.call(this); | ||
function DeviceLogProvider($logFilter, $logger) { | ||
_super.call(this, $logFilter, $logger); | ||
this.$logFilter = $logFilter; | ||
this.devicesLogLevel = {}; | ||
} | ||
DeviceLogProvider.prototype.logData = function (line, platform, deviceIdentifier) { | ||
var logLevel = this.$logFilter.loggingLevel; | ||
if (deviceIdentifier) { | ||
logLevel = this.devicesLogLevel[deviceIdentifier] = this.devicesLogLevel[deviceIdentifier] || this.$logFilter.loggingLevel; | ||
} | ||
var data = this.$logFilter.filterData(platform, line, logLevel); | ||
var logLevel = this.setDefaultLogLevelForDevice(deviceIdentifier); | ||
var applicationPid = this.getApplicationPidForDevice(deviceIdentifier), data = this.$logFilter.filterData(platform, line, applicationPid, logLevel); | ||
if (data) { | ||
@@ -29,8 +25,9 @@ this.emit('data', deviceIdentifier, data); | ||
if (deviceIdentifier) { | ||
this.devicesLogLevel[deviceIdentifier] = logLevel.toUpperCase(); | ||
this.setDeviceLogOptionsProperty(deviceIdentifier, function (deviceLogOptions) { return deviceLogOptions.logLevel; }, logLevel.toUpperCase()); | ||
} | ||
else { | ||
this.$logFilter.loggingLevel = logLevel.toUpperCase(); | ||
_.each(this.devicesLogLevel, function (deviceLogLevel, deviceId) { | ||
_this.devicesLogLevel[deviceId] = _this.$logFilter.loggingLevel; | ||
_.keys(this.devicesLogOptions).forEach(function (deviceId) { | ||
_this.devicesLogOptions[deviceId] = _this.devicesLogOptions[deviceId] || {}; | ||
_this.devicesLogOptions[deviceId].logLevel = _this.$logFilter.loggingLevel; | ||
}); | ||
@@ -40,4 +37,4 @@ } | ||
return DeviceLogProvider; | ||
}(events_1.EventEmitter)); | ||
}(device_log_provider_base_1.DeviceLogProviderBase)); | ||
exports.DeviceLogProvider = DeviceLogProvider; | ||
$injector.register("deviceLogProvider", DeviceLogProvider); |
@@ -18,8 +18,13 @@ "use strict"; | ||
this.ADDITIONAL_FILE_DISPOSITION = "AdditionalFile"; | ||
this.BUILD_RESULT_DISPOSITION = "BuildResult"; | ||
this.ADDITIONAL_FILES_DIRECTORY = ".ab"; | ||
this.REFERENCES_FILE_NAME = ".abreferences.d.ts"; | ||
this.ANDROID_PLATFORM_NAME = "Android"; | ||
this.IOS_PLATFORM_NAME = "iOS"; | ||
this.WP8_PLATFORM_NAME = "WP8"; | ||
this.TSCONFIG_JSON_NAME = "tsconfig.json"; | ||
this.APPBUILDER_PROJECT_PLATFORMS_NAMES = { | ||
android: "Android", | ||
ios: "iOS", | ||
wp8: "WP8" | ||
android: this.ANDROID_PLATFORM_NAME, | ||
ios: this.IOS_PLATFORM_NAME, | ||
wp8: this.WP8_PLATFORM_NAME | ||
}; | ||
@@ -26,0 +31,0 @@ this.IONIC_PROJECT_PLATFORMS_NAMES = { |
"use strict"; | ||
var os_1 = require("os"); | ||
var Future = require("fibers/future"); | ||
var path = require("path"); | ||
var constants_1 = require("../../constants"); | ||
var path = require("path"); | ||
var constants_2 = require("../../constants"); | ||
var ProjectBase = (function () { | ||
@@ -57,10 +56,2 @@ function ProjectBase($cordovaProjectCapabilities, $errors, $fs, $logger, $nativeScriptProjectCapabilities, $options, $projectConstants, $staticConfig) { | ||
}); | ||
Object.defineProperty(ProjectBase.prototype, "startPackageActivity", { | ||
get: function () { | ||
var projectData = this.projectData; | ||
return projectData && projectData.Framework ? constants_2.startPackageActivityNames[projectData.Framework.toLowerCase()] : null; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(ProjectBase.prototype, "hasBuildConfigurations", { | ||
@@ -85,2 +76,27 @@ get: function () { | ||
}); | ||
ProjectBase.prototype.getAppIdentifierForPlatform = function (platform) { | ||
var _this = this; | ||
return (function () { | ||
if (!_this._platformSpecificAppIdentifier) { | ||
_this._platformSpecificAppIdentifier = _this.projectData.AppIdentifier; | ||
if (platform && | ||
platform.toLowerCase() === _this.$projectConstants.ANDROID_PLATFORM_NAME.toLowerCase() && | ||
_this.projectData.Framework === constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova) { | ||
var pathToAndroidResources = path.join(_this.projectDir, _this.$staticConfig.APP_RESOURCES_DIR_NAME, _this.$projectConstants.ANDROID_PLATFORM_NAME); | ||
var pathToAndroidManifest = path.join(pathToAndroidResources, ProjectBase.ANDROID_MANIFEST_NAME); | ||
var appIdentifierInAndroidManifest = _this.getAppIdentifierFromConfigFile(pathToAndroidManifest, /package\s*=\s*"(\S*)"/).wait(); | ||
if (appIdentifierInAndroidManifest && appIdentifierInAndroidManifest !== ProjectBase.APP_IDENTIFIER_PLACEHOLDER) { | ||
_this._platformSpecificAppIdentifier = appIdentifierInAndroidManifest; | ||
} | ||
} | ||
} | ||
return _this._platformSpecificAppIdentifier; | ||
}).future()(); | ||
}; | ||
ProjectBase.prototype.validateAppIdentifier = function (platform) { | ||
var _this = this; | ||
return (function () { | ||
_this.getAppIdentifierForPlatform(platform).wait(); | ||
}).future()(); | ||
}; | ||
ProjectBase.prototype.readProjectData = function () { | ||
@@ -144,6 +160,21 @@ var _this = this; | ||
}; | ||
ProjectBase.prototype.getAppIdentifierFromConfigFile = function (pathToConfigFile, regExp) { | ||
var _this = this; | ||
return (function () { | ||
if (_this.$fs.exists(pathToConfigFile).wait()) { | ||
var fileContent = _this.$fs.readText(pathToConfigFile).wait(); | ||
var matches = fileContent.match(regExp); | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
} | ||
return null; | ||
}).future()(); | ||
}; | ||
ProjectBase.VALID_CONFIGURATION_CHARACTERS_REGEX = "[-_A-Za-z0-9]"; | ||
ProjectBase.CONFIGURATION_FROM_FILE_NAME_REGEX = new RegExp("^[.](" + ProjectBase.VALID_CONFIGURATION_CHARACTERS_REGEX + "+?)[.]abproject$", "i"); | ||
ProjectBase.ANDROID_MANIFEST_NAME = "AndroidManifest.xml"; | ||
ProjectBase.APP_IDENTIFIER_PLACEHOLDER = "$AppIdentifier$"; | ||
return ProjectBase; | ||
}()); | ||
exports.ProjectBase = ProjectBase; |
@@ -7,3 +7,3 @@ "use strict"; | ||
}; | ||
var appbuilder_static_config_base_1 = require("./appbuilder-static-config-base"); | ||
var static_config_base_1 = require("../static-config-base"); | ||
var path = require("path"); | ||
@@ -32,4 +32,4 @@ var ProtonStaticConfig = (function (_super) { | ||
return ProtonStaticConfig; | ||
}(appbuilder_static_config_base_1.AppBuilderStaticConfigBase)); | ||
}(static_config_base_1.StaticConfigBase)); | ||
exports.ProtonStaticConfig = ProtonStaticConfig; | ||
$injector.register("staticConfig", ProtonStaticConfig); |
@@ -23,9 +23,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(AppBuilderLiveSyncProviderBase.prototype, "platformSpecificLiveSyncServices", { | ||
get: function () { | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
AppBuilderLiveSyncProviderBase.prototype.preparePlatformForSync = function (platform) { | ||
@@ -32,0 +25,0 @@ return Future.fromResult(); |
@@ -91,3 +91,3 @@ "use strict"; | ||
function AndroidNativeScriptCompanionAppIdentifier(device, platform, $deployHelper, $devicePlatformsConstants, $companionAppsService) { | ||
_super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova, platform), device, platform, $deployHelper, $devicePlatformsConstants); | ||
_super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript, platform), device, platform, $deployHelper, $devicePlatformsConstants); | ||
this.$companionAppsService = $companionAppsService; | ||
@@ -199,3 +199,3 @@ } | ||
function IOSNativeScriptCompanionAppIdentifier(device, platform, $deployHelper, $devicePlatformsConstants, $companionAppsService) { | ||
_super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova, platform), device, platform, $deployHelper, $devicePlatformsConstants); | ||
_super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript, platform), device, platform, $deployHelper, $devicePlatformsConstants); | ||
this.$companionAppsService = $companionAppsService; | ||
@@ -202,0 +202,0 @@ } |
@@ -57,3 +57,3 @@ "use strict"; | ||
else { | ||
_this.device.fileSystem.deleteFile("/Library/Preferences/ServerInfo.plist", deviceAppData.appIdentifier); | ||
_this.device.fileSystem.deleteFile("/Documents/AppBuilder/ServerInfo.plist", deviceAppData.appIdentifier); | ||
var notificationProxyClient = _this.$injector.resolve(iOSProxyServices.NotificationProxyClient, { device: _this.device }); | ||
@@ -60,0 +60,0 @@ var notification = _this.$project.projectData.Framework === constants_2.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript ? "com.telerik.app.refreshApp" : "com.telerik.app.refreshWebView"; |
@@ -77,3 +77,3 @@ "use strict"; | ||
} | ||
var appIdentifier = _this.$project.projectData.AppIdentifier, canExecute = function (d) { return d.deviceInfo.identifier === device.deviceInfo.identifier; }, livesyncData = { | ||
var appIdentifier = _this.$project.getAppIdentifierForPlatform(_this.$devicesService.platform).wait(), canExecute = function (d) { return d.deviceInfo.identifier === device.deviceInfo.identifier; }, livesyncData = { | ||
platform: device.deviceInfo.platform, | ||
@@ -80,0 +80,0 @@ appIdentifier: appIdentifier, |
@@ -13,5 +13,6 @@ "use strict"; | ||
var os = require("os"); | ||
var constants = require("../../constants"); | ||
var helpers_1 = require("../../helpers"); | ||
var constants = require("../../constants"); | ||
var decorators_1 = require("../../decorators"); | ||
var url = require("url"); | ||
var NpmService = (function () { | ||
@@ -26,3 +27,39 @@ function NpmService($childProcess, $errors, $fs, $hostInfo, $httpClient, $logger, $projectConstants) { | ||
this.$projectConstants = $projectConstants; | ||
this._hasCheckedNpmProxy = false; | ||
} | ||
Object.defineProperty(NpmService.prototype, "npmBinary", { | ||
get: function () { | ||
if (!this._npmBinary) { | ||
try { | ||
require(NpmService.NPM_MODULE_NAME); | ||
var npmMainJsFile = require.resolve(NpmService.NPM_MODULE_NAME); | ||
var pathToNpmBinary = path.join(npmMainJsFile.substring(0, npmMainJsFile.lastIndexOf(constants.NODE_MODULES_DIR_NAME) + constants.NODE_MODULES_DIR_NAME.length), ".bin", this.npmExecutableName); | ||
if (!this.$fs.exists(pathToNpmBinary).wait()) { | ||
throw new Error("The npm binary is not in " + pathToNpmBinary + " as expected."); | ||
} | ||
this._npmBinary = pathToNpmBinary; | ||
} | ||
catch (err) { | ||
this.$logger.trace("Error while trying to get the npm binary: " + err); | ||
this._npmBinary = this.npmExecutableName; | ||
} | ||
} | ||
return this._npmBinary; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(NpmService.prototype, "npmExecutableName", { | ||
get: function () { | ||
if (!this._npmExecutableName) { | ||
this._npmExecutableName = "npm"; | ||
if (this.$hostInfo.isWindows) { | ||
this._npmExecutableName += ".cmd"; | ||
} | ||
} | ||
return this._npmExecutableName; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
NpmService.prototype.install = function (projectDir, dependencyToInstall) { | ||
@@ -77,12 +114,49 @@ var _this = this; | ||
} | ||
_this.generateReferencesFile(projectDir).wait(); | ||
}).future()(); | ||
}; | ||
NpmService.prototype.search = function (projectDir, keywords, args) { | ||
var _this = this; | ||
if (args === void 0) { args = []; } | ||
return (function () { | ||
var result = []; | ||
var commandArguments = _.concat(["search"], args, keywords); | ||
var spawnResult = _this.executeNpmCommandCore(projectDir, commandArguments).wait(); | ||
if (spawnResult.stderr) { | ||
var splitError = spawnResult.stderr.trim().split("\n"); | ||
if (splitError.length > 1 || splitError[0].indexOf("Building the local index for the first time") === -1) { | ||
_this.$errors.failWithoutHelp(spawnResult.stderr); | ||
} | ||
} | ||
var pluginsRows = spawnResult.stdout.split("\n"); | ||
pluginsRows.shift(); | ||
var npmNameGroup = "(\\S+)"; | ||
var npmDateGroup = "(\\d+-\\d+-\\d+)\\s"; | ||
var npmFreeTextGroup = "([^=]+)"; | ||
var npmAuthorsGroup = "((?:=\\S+\\s?)+)\\s+"; | ||
var pluginRowRegExp = new RegExp(npmNameGroup + "\\s+" + npmFreeTextGroup + npmAuthorsGroup + npmDateGroup + npmNameGroup + "(\\s+" + npmFreeTextGroup + ")?"); | ||
_.each(pluginsRows, function (pluginRow) { | ||
var matches = pluginRowRegExp.exec(pluginRow.trim()); | ||
if (!matches || !matches[0]) { | ||
return; | ||
} | ||
result.push({ | ||
name: matches[1], | ||
description: matches[2], | ||
author: matches[3], | ||
version: matches[5] | ||
}); | ||
}); | ||
return result; | ||
}).future()(); | ||
}; | ||
NpmService.prototype.getPackageJsonFromNpmRegistry = function (packageName, version) { | ||
var _this = this; | ||
return (function () { | ||
var timeout = 6000; | ||
var packageJsonContent; | ||
version = version || "latest"; | ||
try { | ||
var url = _this.buildNpmRegistryUrl(packageName, version); | ||
var result = _this.$httpClient.httpRequest(url).wait().body; | ||
var url_1 = _this.buildNpmRegistryUrl(packageName, version).wait(), proxySettings = _this.getNpmProxySettings().wait(); | ||
var result = _this.$httpClient.httpRequest({ url: url_1, timeout: timeout }, proxySettings).wait().body; | ||
packageJsonContent = JSON.parse(result); | ||
@@ -97,2 +171,14 @@ } | ||
}; | ||
NpmService.prototype.isScopedDependency = function (dependency) { | ||
var matches = dependency.match(NpmService.SCOPED_DEPENDENCY_REGEXP); | ||
return !!(matches && matches[0]); | ||
}; | ||
NpmService.prototype.getDependencyInformation = function (dependency) { | ||
var regExp = this.isScopedDependency(dependency) ? NpmService.SCOPED_DEPENDENCY_REGEXP : NpmService.DEPENDENCY_REGEXP; | ||
var matches = dependency.match(regExp); | ||
return { | ||
name: matches[1], | ||
version: matches[2] | ||
}; | ||
}; | ||
NpmService.prototype.hasTypesForDependency = function (packageName) { | ||
@@ -105,4 +191,28 @@ var _this = this; | ||
NpmService.prototype.buildNpmRegistryUrl = function (packageName, version) { | ||
return NpmService.NPM_REGISTRY_URL + "/" + packageName.replace("/", "%2F") + "?version=" + encodeURIComponent(version); | ||
var _this = this; | ||
return (function () { | ||
var registryUrl = _this.getNpmRegistryUrl().wait(); | ||
if (!_.endsWith(registryUrl, "/")) { | ||
registryUrl += "/"; | ||
} | ||
return "" + registryUrl + packageName.replace("/", "%2F") + "?version=" + encodeURIComponent(version); | ||
}).future()(); | ||
}; | ||
NpmService.prototype.getNpmRegistryUrl = function () { | ||
var _this = this; | ||
return (function () { | ||
if (!_this._npmRegistryUrl) { | ||
var currentNpmRegistry = void 0; | ||
try { | ||
currentNpmRegistry = (_this.$childProcess.exec("npm config get registry").wait() || "").toString().trim(); | ||
} | ||
catch (err) { | ||
_this.$logger.trace("Unable to get registry from npm config. Error is " + err.message + "."); | ||
} | ||
_this._npmRegistryUrl = currentNpmRegistry || NpmService.NPM_REGISTRY_URL; | ||
_this.$logger.trace("Npm registry is: " + _this._npmRegistryUrl + "."); | ||
} | ||
return _this._npmRegistryUrl; | ||
}).future()(); | ||
}; | ||
NpmService.prototype.getPackageJsonContent = function (projectDir) { | ||
@@ -170,15 +280,2 @@ var _this = this; | ||
}; | ||
Object.defineProperty(NpmService.prototype, "npmExecutableName", { | ||
get: function () { | ||
if (!this._npmExecutableName) { | ||
this._npmExecutableName = "npm"; | ||
if (this.$hostInfo.isWindows) { | ||
this._npmExecutableName += ".cmd"; | ||
} | ||
} | ||
return this._npmExecutableName; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
NpmService.prototype.getNpmArguments = function (command, npmArguments) { | ||
@@ -207,8 +304,37 @@ if (npmArguments === void 0) { npmArguments = []; } | ||
} | ||
_this.$childProcess.spawnFromEvent(_this.npmExecutableName, npmArguments, "close", { cwd: projectDir }).wait(); | ||
return _this.executeNpmCommandCore(projectDir, npmArguments).wait(); | ||
}).future()(); | ||
}; | ||
NpmService.prototype.executeNpmCommandCore = function (projectDir, npmArguments) { | ||
return this.$childProcess.spawnFromEvent(this.npmExecutableName, npmArguments, "close", { cwd: projectDir }); | ||
}; | ||
NpmService.prototype.getNpmProxySettings = function () { | ||
var _this = this; | ||
return (function () { | ||
if (!_this._hasCheckedNpmProxy) { | ||
try { | ||
var npmProxy = (_this.$childProcess.exec("npm config get proxy").wait() || "").toString().trim(); | ||
if (npmProxy && npmProxy !== "null") { | ||
var uri = url.parse(npmProxy); | ||
_this._proxySettings = { | ||
hostname: uri.hostname, | ||
port: uri.port | ||
}; | ||
} | ||
} | ||
catch (err) { | ||
_this.$logger.trace("Unable to get npm proxy configuration. Error is: " + err.message + "."); | ||
} | ||
_this.$logger.trace("Npm proxy is: ", _this._proxySettings); | ||
_this._hasCheckedNpmProxy = true; | ||
} | ||
return _this._proxySettings; | ||
}).future()(); | ||
}; | ||
NpmService.NPM_MODULE_NAME = "npm"; | ||
NpmService.TYPES_DIRECTORY = "@types/"; | ||
NpmService.TNS_CORE_MODULES_DEFINITION_FILE_NAME = "" + constants.TNS_CORE_MODULES + constants.FileExtensions.TYPESCRIPT_DEFINITION_FILE; | ||
NpmService.NPM_REGISTRY_URL = "https://registry.npmjs.org"; | ||
NpmService.NPM_REGISTRY_URL = "http://registry.npmjs.org"; | ||
NpmService.SCOPED_DEPENDENCY_REGEXP = /^(@.+?)(?:@(.+?))?$/; | ||
NpmService.DEPENDENCY_REGEXP = /^(.+?)(?:@(.+?))?$/; | ||
__decorate([ | ||
@@ -215,0 +341,0 @@ decorators_1.exportedPromise("npmService"), |
@@ -11,2 +11,3 @@ global._ = require("lodash"); | ||
$injector.require("hostInfo", "./host-info"); | ||
$injector.require("osInfo", "./os-info"); | ||
$injector.require("dispatcher", "./dispatchers"); | ||
@@ -69,4 +70,6 @@ $injector.require("commandDispatcher", "./dispatchers"); | ||
$injector.require("iOSSimResolver", "./mobile/ios/simulator/ios-sim-resolver"); | ||
$injector.require("iOSSimulatorLogProvider", "./mobile/ios/simulator/ios-simulator-log-provider"); | ||
$injector.require("localToDevicePathDataFactory", "./mobile/local-to-device-path-data-factory"); | ||
$injector.require("deviceAppDataFactory", "./mobile/device-app-data/device-app-data-factory"); | ||
$injector.requirePublic("typeScriptService", "./services/typescript-service"); | ||
$injector.requirePublic("devicesService", "./mobile/mobile-core/devices-service"); | ||
@@ -96,5 +99,6 @@ $injector.require("androidProcessService", "./mobile/mobile-core/android-process-service"); | ||
$injector.require("androidLogFilter", "./mobile/android/android-log-filter"); | ||
$injector.require("iOSLogFilter", "./mobile/ios/ios-log-filter"); | ||
$injector.require("projectFilesManager", "./services/project-files-manager"); | ||
$injector.require("xcodeSelectService", "./services/xcode-select-service"); | ||
$injector.require("net", "./services/net-service"); | ||
$injector.require("printPluginsService", "./services/plugins/print-plugins-service"); | ||
$injector.require("npmPluginsService", "./services/plugins/npm-plugins-service"); |
@@ -26,10 +26,6 @@ "use strict"; | ||
LiveSyncConstants.CHECK_LIVESYNC_INTENT_NAME = "com.telerik.IsLiveSyncSupported"; | ||
LiveSyncConstants.IOS_PROJECT_PATH = "/Library/Application Support/LiveSync"; | ||
LiveSyncConstants.IOS_PROJECT_PATH = "/Documents/AppBuilder/LiveSync"; | ||
return LiveSyncConstants; | ||
}()); | ||
exports.LiveSyncConstants = LiveSyncConstants; | ||
exports.startPackageActivityNames = { | ||
"nativescript": "com.tns.NativeScriptActivity", | ||
"cordova": ".TelerikCallbackActivity" | ||
}; | ||
exports.TARGET_FRAMEWORK_IDENTIFIERS = { | ||
@@ -36,0 +32,0 @@ Cordova: "Cordova", |
@@ -259,3 +259,5 @@ "use strict"; | ||
FileSystem.prototype.writeJson = function (filename, data, space, encoding) { | ||
if (space === void 0) { space = "\t"; } | ||
if (!space) { | ||
space = this.getIndentationCharacter(filename).wait(); | ||
} | ||
return this.writeFile(filename, JSON.stringify(data, null, space), encoding); | ||
@@ -319,2 +321,14 @@ }; | ||
}; | ||
FileSystem.prototype.getLsStats = function (path) { | ||
var future = new Future(); | ||
fs.lstat(path, function (err, data) { | ||
if (err) { | ||
future.throw(err); | ||
} | ||
else { | ||
future.return(data); | ||
} | ||
}); | ||
return future; | ||
}; | ||
FileSystem.prototype.getUniqueFileName = function (baseName) { | ||
@@ -419,2 +433,7 @@ var _this = this; | ||
foundFiles = foundFiles || []; | ||
if (!this.exists(directoryPath).wait()) { | ||
var $logger = this.$injector.resolve("logger"); | ||
$logger.warn('Could not find folder: ' + directoryPath); | ||
return foundFiles; | ||
} | ||
var contents = this.readDirectory(directoryPath).wait(); | ||
@@ -477,2 +496,29 @@ for (var i = 0; i < contents.length; ++i) { | ||
}; | ||
FileSystem.prototype.deleteEmptyParents = function (directory) { | ||
var _this = this; | ||
return (function () { | ||
var parent = _this.exists(directory).wait() ? directory : path.dirname(directory); | ||
while (_this.isEmptyDir(parent).wait()) { | ||
_this.deleteDirectory(parent).wait(); | ||
parent = path.dirname(parent); | ||
} | ||
}).future()(); | ||
}; | ||
FileSystem.prototype.getIndentationCharacter = function (filePath) { | ||
var _this = this; | ||
return (function () { | ||
if (!_this.exists(filePath).wait()) { | ||
return FileSystem.DEFAULT_INDENTATION_CHARACTER; | ||
} | ||
var fileContent = _this.readText(filePath).wait().trim(); | ||
var matches = fileContent.match(FileSystem.JSON_OBJECT_REGEXP); | ||
if (!matches || !matches[1]) { | ||
return FileSystem.DEFAULT_INDENTATION_CHARACTER; | ||
} | ||
var indentation = matches[1]; | ||
return indentation[0] === " " ? indentation : FileSystem.DEFAULT_INDENTATION_CHARACTER; | ||
}).future()(); | ||
}; | ||
FileSystem.DEFAULT_INDENTATION_CHARACTER = "\t"; | ||
FileSystem.JSON_OBJECT_REGEXP = new RegExp("{\\r*\\n*(\\W*)\"", "m"); | ||
__decorate([ | ||
@@ -479,0 +525,0 @@ decorators.exportedPromise("fs"), |
@@ -7,2 +7,12 @@ "use strict"; | ||
var os_1 = require("os"); | ||
function getPropertyName(func) { | ||
if (func) { | ||
var match = func.toString().match(/(?:return\s+?.*\.(.+);)|(?:=>\s*?.*\.(.+)\b)/); | ||
if (match) { | ||
return (match[1] || match[2]).trim(); | ||
} | ||
} | ||
return null; | ||
} | ||
exports.getPropertyName = getPropertyName; | ||
function bashQuote(s) { | ||
@@ -95,3 +105,3 @@ if (s[0] === "'" && s[s.length - 1] === "'") { | ||
function toBoolean(str) { | ||
return str && str.toString().toLowerCase() === "true"; | ||
return !!(str && str.toString && str.toString().toLowerCase() === "true"); | ||
} | ||
@@ -118,6 +128,6 @@ exports.toBoolean = toBoolean; | ||
function isNullOrWhitespace(input) { | ||
if (!input) { | ||
if (!input && input !== false) { | ||
return true; | ||
} | ||
return input.replace(/\s/gi, "").length < 1; | ||
return _.isString(input) && input.replace(/\s/gi, "").length < 1; | ||
} | ||
@@ -213,3 +223,3 @@ exports.isNullOrWhitespace = isNullOrWhitespace; | ||
} | ||
function prepareArguments(method, args) { | ||
function prepareArguments(method, args, hooksService) { | ||
annotate(method); | ||
@@ -221,11 +231,13 @@ var argHash = {}; | ||
argHash.$arguments = args; | ||
return { | ||
hookArgs: argHash | ||
}; | ||
var result = {}; | ||
result[hooksService.hookArgsName] = argHash; | ||
return result; | ||
} | ||
return decorateMethod(function (method, self, args) { | ||
getHooksService(self).executeBeforeHooks(commandName, prepareArguments(method, args)).wait(); | ||
var hooksService = getHooksService(self); | ||
hooksService.executeBeforeHooks(commandName, prepareArguments(method, args, hooksService)).wait(); | ||
}, function (method, self, resultPromise, args) { | ||
var result = resultPromise.wait(); | ||
getHooksService(self).executeAfterHooks(commandName, prepareArguments(method, args)).wait(); | ||
var hooksService = getHooksService(self); | ||
hooksService.executeAfterHooks(commandName, prepareArguments(method, args, hooksService)).wait(); | ||
return Future.fromResult(result); | ||
@@ -232,0 +244,0 @@ }); |
@@ -15,3 +15,3 @@ "use strict"; | ||
} | ||
HttpClient.prototype.httpRequest = function (options) { | ||
HttpClient.prototype.httpRequest = function (options, proxySettings) { | ||
var _this = this; | ||
@@ -46,7 +46,7 @@ return (function () { | ||
var headers = options.headers; | ||
if (_this.$config.USE_PROXY) { | ||
if (proxySettings || _this.$config.USE_PROXY) { | ||
options.path = requestProto + "://" + options.host + options.path; | ||
headers.Host = options.host; | ||
options.host = _this.$config.PROXY_HOSTNAME; | ||
options.port = _this.$config.PROXY_PORT; | ||
options.host = (proxySettings && proxySettings.hostname) || _this.$config.PROXY_HOSTNAME; | ||
options.port = (proxySettings && proxySettings.port) || _this.$config.PROXY_PORT; | ||
_this.$logger.trace("Using proxy with host: %s, port: %d, path is: %s", options.host, options.port, options.path); | ||
@@ -73,3 +73,9 @@ } | ||
} | ||
var result = new Future(); | ||
var result = new Future(), timerId; | ||
if (options.timeout) { | ||
timerId = setTimeout(function () { | ||
_this.setResponseResult(result, timerId, { err: new Error("Request to " + unmodifiedOptions.url + " timed out.") }); | ||
}, options.timeout); | ||
delete options.timeout; | ||
} | ||
_this.$logger.trace("httpRequest: %s", util.inspect(options)); | ||
@@ -95,8 +101,3 @@ var request = http.request(options, function (response) { | ||
_this.$logger.trace("httpRequest: Piping done. code = %d", response.statusCode.toString()); | ||
if (!result.isResolved()) { | ||
result.return({ | ||
response: response, | ||
headers: response.headers | ||
}); | ||
} | ||
_this.setResponseResult(result, timerId, { response: response }); | ||
}); | ||
@@ -114,16 +115,10 @@ pipeTo = _this.trackDownloadProgress(pipeTo); | ||
if (successful || isRedirect) { | ||
if (!result.isResolved()) { | ||
result.return({ | ||
body: responseBody, | ||
response: response, | ||
headers: response.headers | ||
}); | ||
} | ||
_this.setResponseResult(result, timerId, { body: responseBody, response: response }); | ||
} | ||
else { | ||
var errorMessage = _this.getErrorMessage(response, responseBody); | ||
var theError = new Error(errorMessage); | ||
theError.response = response; | ||
theError.body = responseBody; | ||
result.throw(theError); | ||
var err = new Error(errorMessage); | ||
err.response = response; | ||
err.body = responseBody; | ||
_this.setResponseResult(result, timerId, { err: err }); | ||
} | ||
@@ -133,6 +128,4 @@ }); | ||
}); | ||
request.on("error", function (error) { | ||
if (!result.isResolved()) { | ||
result.throw(error); | ||
} | ||
request.on("error", function (err) { | ||
_this.setResponseResult(result, timerId, { err: err }); | ||
}); | ||
@@ -158,2 +151,16 @@ _this.$logger.trace("httpRequest: Sending:\n%s", _this.$logger.prepare(body)); | ||
}; | ||
HttpClient.prototype.setResponseResult = function (result, timerId, resultData) { | ||
if (timerId) { | ||
clearTimeout(timerId); | ||
timerId = null; | ||
} | ||
if (!result.isResolved()) { | ||
if (resultData.err) { | ||
return result.throw(resultData.err); | ||
} | ||
var finalResult = resultData; | ||
finalResult.headers = resultData.response.headers; | ||
result.return(finalResult); | ||
} | ||
}; | ||
HttpClient.prototype.trackDownloadProgress = function (pipeTo) { | ||
@@ -160,0 +167,0 @@ var _this = this; |
@@ -45,12 +45,6 @@ "use strict"; | ||
return (function () { | ||
var startActivityName = _this.getStartPackageActivity(framework); | ||
var defaultActivityNames = [constants_1.startPackageActivityNames[constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase()], | ||
constants_1.startPackageActivityNames[constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript.toLowerCase()]]; | ||
var startActivityNames = startActivityName ? [startActivityName] : defaultActivityNames; | ||
_.each(startActivityNames, function (activityName) { | ||
_this.adb.executeShellCommand(["am", "start", | ||
"-a", "android.intent.action.MAIN", | ||
"-n", (appIdentifier + "/" + activityName), | ||
"-c", "android.intent.category.LAUNCHER"]).wait(); | ||
}); | ||
_this.adb.executeShellCommand(["monkey", | ||
"-p", appIdentifier, | ||
"-c", "android.intent.category.LAUNCHER", | ||
"1"]).wait(); | ||
if (!_this.$options.justlaunch) { | ||
@@ -100,8 +94,4 @@ _this.$logcatHelper.start(_this.identifier); | ||
}; | ||
AndroidApplicationManager.prototype.getStartPackageActivity = function (framework) { | ||
framework = framework || ""; | ||
return constants_1.startPackageActivityNames[framework.toLowerCase()] || this.$staticConfig.START_PACKAGE_ACTIVITY_NAME; | ||
}; | ||
return AndroidApplicationManager; | ||
}(application_manager_base_1.ApplicationManagerBase)); | ||
exports.AndroidApplicationManager = AndroidApplicationManager; |
@@ -69,2 +69,5 @@ "use strict"; | ||
return (function () { | ||
if (!_this.getEmulatorImage().wait()) { | ||
_this.$errors.failWithoutHelp("You do not have any Android emulators installed. Please install at least one."); | ||
} | ||
var platform = _this.$devicePlatformsConstants.Android; | ||
@@ -150,3 +153,3 @@ if (!_this.$emulatorSettingsService.canStart(platform).wait()) { | ||
}; | ||
childProcess = adb.executeShellCommand(["am", "start", "-S", appId + "/" + _this.$staticConfig.START_PACKAGE_ACTIVITY_NAME], androidDebugBridgeCommandOptions).wait(); | ||
childProcess = adb.executeShellCommand(["monkey", "-p", appId, "-c", "android.intent.category.LAUNCHER", "1"], androidDebugBridgeCommandOptions).wait(); | ||
_this.$fs.futureFromEvent(childProcess, "close").wait(); | ||
@@ -330,3 +333,3 @@ if (!_this.$options.justlaunch) { | ||
.maxBy(function (avd) { return avd.targetNum; }); | ||
return (best.targetNum >= minVersion) ? best.name : null; | ||
return (best && best.targetNum >= minVersion) ? best.name : null; | ||
}).future()(); | ||
@@ -350,2 +353,5 @@ }; | ||
return (function () { | ||
if (!_this.$fs.exists(avdFileName).wait()) { | ||
return null; | ||
} | ||
var encoding = _this.getAvdEncoding(avdFileName).wait(); | ||
@@ -352,0 +358,0 @@ var contents = _this.$fs.readText(avdFileName, encoding).wait().split("\n"); |
"use strict"; | ||
var byline = require("byline"); | ||
var device_android_debug_bridge_1 = require("./device-android-debug-bridge"); | ||
var fiberBootstrap = require("../../fiber-bootstrap"); | ||
var LogcatHelper = (function () { | ||
@@ -36,3 +37,5 @@ function LogcatHelper($childProcess, $deviceLogProvider, $devicePlatformsConstants, $logger, $injector, $processService) { | ||
var lineText = line.toString(); | ||
_this.$deviceLogProvider.logData(lineText, _this.$devicePlatformsConstants.Android, deviceIdentifier); | ||
fiberBootstrap.run(function () { | ||
return _this.$deviceLogProvider.logData(lineText, _this.$devicePlatformsConstants.Android, deviceIdentifier); | ||
}); | ||
}); | ||
@@ -39,0 +42,0 @@ this.$processService.attachToProcessExitSignals(this, adbLogcat.kill); |
"use strict"; | ||
var DeviceLogProvider = (function () { | ||
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 device_log_provider_base_1 = require("./device-log-provider-base"); | ||
var DeviceLogProvider = (function (_super) { | ||
__extends(DeviceLogProvider, _super); | ||
function DeviceLogProvider($logFilter, $logger) { | ||
_super.call(this, $logFilter, $logger); | ||
this.$logFilter = $logFilter; | ||
@@ -8,3 +16,4 @@ this.$logger = $logger; | ||
DeviceLogProvider.prototype.logData = function (lineText, platform, deviceIdentifier) { | ||
var data = this.$logFilter.filterData(platform, lineText); | ||
var applicationPid = this.getApplicationPidForDevice(deviceIdentifier); | ||
var data = this.$logFilter.filterData(platform, lineText, applicationPid); | ||
if (data) { | ||
@@ -18,4 +27,4 @@ this.$logger.out(data); | ||
return DeviceLogProvider; | ||
}()); | ||
}(device_log_provider_base_1.DeviceLogProviderBase)); | ||
exports.DeviceLogProvider = DeviceLogProvider; | ||
$injector.register("deviceLogProvider", DeviceLogProvider); |
@@ -16,3 +16,3 @@ "use strict"; | ||
__extends(IOSApplicationManager, _super); | ||
function IOSApplicationManager($logger, device, devicePointer, $childProcess, $coreFoundation, $errors, $injector, $mobileDevice, $hostInfo, $staticConfig, $devicePlatformsConstants, $options) { | ||
function IOSApplicationManager($logger, device, devicePointer, $childProcess, $coreFoundation, $errors, $injector, $mobileDevice, $hostInfo, $staticConfig, $devicePlatformsConstants, $processService, $options) { | ||
_super.call(this, $logger); | ||
@@ -30,2 +30,3 @@ this.$logger = $logger; | ||
this.$devicePlatformsConstants = $devicePlatformsConstants; | ||
this.$processService = $processService; | ||
this.$options = $options; | ||
@@ -144,3 +145,3 @@ this.uninstallApplicationCallbackPtr = null; | ||
var application = this.getApplicationById(appIdentifier); | ||
var gdbServer = this.createGdbServer(); | ||
var gdbServer = this.createGdbServer(this.device.deviceInfo.identifier); | ||
return gdbServer.kill([("" + application.Path)]); | ||
@@ -188,18 +189,22 @@ }; | ||
IOSApplicationManager.prototype.runApplicationCore = function (appIdentifier) { | ||
if (this._gdbServer) { | ||
this._gdbServer.destroy(); | ||
this._gdbServer = null; | ||
} | ||
this.destroyGdbServer(); | ||
var application = this.getApplicationById(appIdentifier); | ||
var gdbServer = this.createGdbServer(); | ||
var gdbServer = this.createGdbServer(this.device.deviceInfo.identifier); | ||
return gdbServer.run([("" + application.Path)]); | ||
}; | ||
IOSApplicationManager.prototype.createGdbServer = function () { | ||
IOSApplicationManager.prototype.createGdbServer = function (deviceIdentifier) { | ||
if (!this._gdbServer) { | ||
var service = this.device.startService(iOSProxyServices.MobileServices.DEBUG_SERVER); | ||
var socket = this.$hostInfo.isWindows ? service : new net.Socket({ fd: service }); | ||
this._gdbServer = this.$injector.resolve(ios_core_1.GDBServer, { socket: socket }); | ||
this._gdbServer = this.$injector.resolve(ios_core_1.GDBServer, { socket: socket, deviceIdentifier: deviceIdentifier }); | ||
this.$processService.attachToProcessExitSignals(this, this.destroyGdbServer); | ||
} | ||
return this._gdbServer; | ||
}; | ||
IOSApplicationManager.prototype.destroyGdbServer = function () { | ||
if (this._gdbServer) { | ||
this._gdbServer.destroy(); | ||
this._gdbServer = null; | ||
} | ||
}; | ||
IOSApplicationManager.prototype.getApplicationById = function (appIdentifier) { | ||
@@ -206,0 +211,0 @@ return this.validateApplicationId(appIdentifier); |
@@ -23,2 +23,3 @@ "use strict"; | ||
var os_1 = require("os"); | ||
var fiberBootstrap = require("../../../fiber-bootstrap"); | ||
var CoreTypes = (function () { | ||
@@ -862,4 +863,3 @@ function CoreTypes() { | ||
.on("data", function (data) { | ||
var output = ref.readCString(data, 0); | ||
action(output); | ||
action(data.toString()); | ||
}) | ||
@@ -902,6 +902,7 @@ .on("end", function () { | ||
var PlistService = (function () { | ||
function PlistService(service, format, $injector, $hostInfo) { | ||
function PlistService(service, format, $injector, $processService, $hostInfo) { | ||
this.service = service; | ||
this.format = format; | ||
this.$injector = $injector; | ||
this.$processService = $processService; | ||
this.$hostInfo = $hostInfo; | ||
@@ -915,2 +916,3 @@ this.socket = null; | ||
} | ||
this.$processService.attachToProcessExitSignals(this, this.close); | ||
} | ||
@@ -951,9 +953,13 @@ PlistService.prototype.receiveMessage = function () { | ||
__extends(GDBStandardOutputAdapter, _super); | ||
function GDBStandardOutputAdapter(opts) { | ||
_super.call(this, opts); | ||
function GDBStandardOutputAdapter(deviceIdentifier, $deviceLogProvider, $devicePlatformsConstants) { | ||
_super.call(this); | ||
this.deviceIdentifier = deviceIdentifier; | ||
this.$deviceLogProvider = $deviceLogProvider; | ||
this.$devicePlatformsConstants = $devicePlatformsConstants; | ||
this.utf8StringDecoder = new string_decoder.StringDecoder("utf8"); | ||
} | ||
GDBStandardOutputAdapter.prototype._transform = function (packet, encoding, done) { | ||
var _this = this; | ||
try { | ||
var result = ""; | ||
var result_1 = ""; | ||
for (var i = 0; i < packet.length; i++) { | ||
@@ -974,6 +980,11 @@ if (packet[i] === getCharacterCodePoint("$")) { | ||
var hex = new Buffer(hexString, "hex"); | ||
result += this.utf8StringDecoder.write(hex); | ||
result_1 += this.utf8StringDecoder.write(hex); | ||
} | ||
} | ||
done(null, result); | ||
if (this.$deviceLogProvider) { | ||
fiberBootstrap.run(function () { | ||
return _this.$deviceLogProvider.logData(result_1, _this.$devicePlatformsConstants.iOS, _this.deviceIdentifier); | ||
}); | ||
} | ||
done(null, result_1); | ||
} | ||
@@ -993,5 +1004,10 @@ catch (e) { | ||
try { | ||
for (var i = 0; i < packet.length - 2; i++) { | ||
if (packet[i] === getCharacterCodePoint("$") && (packet[i + 1] === getCharacterCodePoint("T") || packet[i + 1] === getCharacterCodePoint("S"))) { | ||
if (packet[i + 2] === getCharacterCodePoint("9")) { | ||
var dollarCodePoint = getCharacterCodePoint("$"); | ||
var TCodePoint = getCharacterCodePoint("T"); | ||
var SCodePoint = getCharacterCodePoint("S"); | ||
for (var i = 0; i < packet.length - 3; i++) { | ||
if (packet[i] === dollarCodePoint && (packet[i + 1] === TCodePoint || packet[i + 1] === SCodePoint)) { | ||
var signalHex = packet.toString("ascii", i + 2, i + 4); | ||
var signalDecimal = parseInt(signalHex, 16); | ||
if (signalDecimal === 5 || signalDecimal === 6 || signalDecimal === 9 || signalDecimal === 11 || signalDecimal === 145) { | ||
process.exit(1); | ||
@@ -1010,5 +1026,6 @@ } | ||
var GDBServer = (function () { | ||
function GDBServer(socket, $injector, $hostInfo, $options, $logger, $errors) { | ||
function GDBServer(socket, deviceIdentifier, $injector, $hostInfo, $options, $logger, $errors) { | ||
var _this = this; | ||
this.socket = socket; | ||
this.deviceIdentifier = deviceIdentifier; | ||
this.$injector = $injector; | ||
@@ -1063,3 +1080,3 @@ this.$hostInfo = $hostInfo; | ||
else { | ||
_this.socket.pipe(new GDBStandardOutputAdapter()).pipe(process.stdout); | ||
_this.socket.pipe(_this.$injector.resolve(GDBStandardOutputAdapter, { deviceIdentifier: _this.deviceIdentifier })); | ||
_this.socket.pipe(new GDBSignalWatcher()); | ||
@@ -1066,0 +1083,0 @@ _this.sendCore(_this.encodeData("vCont;c")); |
@@ -68,4 +68,4 @@ "use strict"; | ||
var houseArrestClient = this.$injector.resolve(iOSProxyServices.HouseArrestClient, { device: this.device }); | ||
var afcClientForContainer = houseArrestClient.getAfcClientForAppContainer(appIdentifier); | ||
afcClientForContainer.deleteFile(deviceFilePath); | ||
var afcClient = this.getAfcClient(houseArrestClient, deviceFilePath, appIdentifier); | ||
afcClient.deleteFile(deviceFilePath); | ||
houseArrestClient.closeSocket(); | ||
@@ -77,7 +77,7 @@ }; | ||
var houseArrestClient = _this.$injector.resolve(iOSProxyServices.HouseArrestClient, { device: _this.device }); | ||
var afcClientForAppContainer = houseArrestClient.getAfcClientForAppContainer(deviceAppData.appIdentifier); | ||
var afcClient = _this.getAfcClient(houseArrestClient, deviceAppData.deviceProjectRootPath, deviceAppData.appIdentifier); | ||
_.each(localToDevicePaths, function (localToDevicePathData) { | ||
var stats = _this.$fs.getFsStats(localToDevicePathData.getLocalPath()).wait(); | ||
if (stats.isFile()) { | ||
afcClientForAppContainer.transfer(localToDevicePathData.getLocalPath(), localToDevicePathData.getDevicePath()).wait(); | ||
afcClient.transfer(localToDevicePathData.getLocalPath(), localToDevicePathData.getDevicePath()).wait(); | ||
} | ||
@@ -91,2 +91,8 @@ }); | ||
}; | ||
IOSDeviceFileSystem.prototype.getAfcClient = function (houseArrestClient, rootPath, appIdentifier) { | ||
if (rootPath.indexOf("/Documents/") === 0) { | ||
return houseArrestClient.getAfcClientForAppDocuments(appIdentifier); | ||
} | ||
return houseArrestClient.getAfcClientForAppContainer(appIdentifier); | ||
}; | ||
IOSDeviceFileSystem.prototype.resolveAfc = function () { | ||
@@ -93,0 +99,0 @@ var service = this.$options.app ? this.startHouseArrestService(this.$options.app) : this.device.startService(iOSProxyServices.MobileServices.APPLE_FILE_CONNECTION); |
@@ -12,3 +12,3 @@ "use strict"; | ||
var IOSDevice = (function () { | ||
function IOSDevice(devicePointer, $coreFoundation, $errors, $fs, $injector, $logger, $mobileDevice, $devicePlatformsConstants, $hostInfo, $options, $iOSDeviceProductNameMapper, $xcodeSelectService) { | ||
function IOSDevice(devicePointer, $coreFoundation, $errors, $fs, $injector, $logger, $mobileDevice, $devicePlatformsConstants, $hostInfo, $options, $iOSDeviceProductNameMapper, $processService, $xcodeSelectService) { | ||
this.devicePointer = devicePointer; | ||
@@ -25,2 +25,3 @@ this.$coreFoundation = $coreFoundation; | ||
this.$iOSDeviceProductNameMapper = $iOSDeviceProductNameMapper; | ||
this.$processService = $processService; | ||
this.$xcodeSelectService = $xcodeSelectService; | ||
@@ -107,3 +108,3 @@ this.mountImageCallbackPtr = null; | ||
if (result !== 0) { | ||
this.$errors.fail(util.format("%s. Result code is: %s", error, result)); | ||
this.$errors.fail({ formatStr: error + ". Result code is: " + result, errorCode: result }); | ||
} | ||
@@ -322,2 +323,4 @@ else { | ||
} | ||
this._socket = socket_1; | ||
this.$processService.attachToProcessExitSignals(this, this.destroySocket); | ||
return socket_1; | ||
@@ -327,2 +330,8 @@ } | ||
}; | ||
IOSDevice.prototype.destroySocket = function () { | ||
if (this._socket) { | ||
this._socket.destroy(); | ||
this._socket = null; | ||
} | ||
}; | ||
IOSDevice.prototype.htons = function (port) { | ||
@@ -329,0 +338,0 @@ var result = (port & 0xff00) >> 8 | (port & 0x00ff) << 8; |
@@ -13,2 +13,3 @@ "use strict"; | ||
var Future = require("fibers/future"); | ||
var fiberBootstrap = require("../../../fiber-bootstrap"); | ||
var MobileServices = (function () { | ||
@@ -24,2 +25,3 @@ function MobileServices() { | ||
MobileServices.DEBUG_SERVER = "com.apple.debugserver"; | ||
MobileServices.NO_WIFI_SYNC_ERROR_CODE = 3892314239; | ||
return MobileServices; | ||
@@ -265,4 +267,3 @@ }()); | ||
afcClient.transferPackage(packageFile, devicePath).wait(); | ||
var installationService = _this.device.startService(MobileServices.INSTALLATION_PROXY); | ||
_this.plistService = _this.getPlistService(installationService); | ||
_this.plistService = _this.getPlistService(); | ||
_this.plistService.sendMessage({ | ||
@@ -278,4 +279,3 @@ Command: "Install", | ||
return (function () { | ||
var service = _this.device.startService(MobileServices.INSTALLATION_PROXY); | ||
_this.plistService = _this.getPlistService(service); | ||
_this.plistService = _this.getPlistService(); | ||
_this.plistService.sendMessage(message); | ||
@@ -294,5 +294,21 @@ var response = _this.plistService.receiveMessage().wait(); | ||
}; | ||
InstallationProxyClient.prototype.getPlistService = function (service) { | ||
InstallationProxyClient.prototype.getPlistService = function () { | ||
var service = this.getInstallationService(); | ||
return this.$injector.resolve(iOSCore.PlistService, { service: service, format: iOSCore.CoreTypes.kCFPropertyListBinaryFormat_v1_0 }); | ||
}; | ||
InstallationProxyClient.prototype.getInstallationService = function () { | ||
var service; | ||
try { | ||
service = this.device.startService(MobileServices.INSTALLATION_PROXY); | ||
} | ||
catch (err) { | ||
if (err.code === MobileServices.NO_WIFI_SYNC_ERROR_CODE) { | ||
this.$logger.trace("Unable to start " + MobileServices.INSTALLATION_PROXY + ". Looks like the problem is with WIFI sync: " + err.message); | ||
this.$logger.printMarkdown("Unable to start installation service. Looks like `Sync over Wi-Fi` option in iTunes is enabled. " + | ||
"Try disabling it, reconnect the device and execute your command again."); | ||
} | ||
this.$errors.failWithoutHelp(err); | ||
} | ||
return service; | ||
}; | ||
return InstallationProxyClient; | ||
@@ -424,2 +440,5 @@ }()); | ||
}; | ||
HouseArrestClient.prototype.getAfcClientForAppDocuments = function (applicationIdentifier) { | ||
return this.getAfcClientCore("VendDocuments", applicationIdentifier); | ||
}; | ||
HouseArrestClient.prototype.closeSocket = function () { | ||
@@ -446,3 +465,5 @@ this.plistService.close(); | ||
var printData = function (data) { | ||
_this.$deviceLogProvider.logData(data, _this.$devicePlatformsConstants.iOS, _this.device.deviceInfo.identifier); | ||
fiberBootstrap.run(function () { | ||
return _this.$deviceLogProvider.logData(data, _this.$devicePlatformsConstants.iOS, _this.device.deviceInfo.identifier); | ||
}); | ||
}; | ||
@@ -449,0 +470,0 @@ this.plistService.readSystemLog(printData); |
@@ -6,5 +6,8 @@ "use strict"; | ||
} | ||
IOSLogFilter.prototype.filterData = function (data, logLevel) { | ||
IOSLogFilter.prototype.filterData = function (data, logLevel, pid) { | ||
var specifiedLogLevel = (logLevel || '').toUpperCase(); | ||
if (specifiedLogLevel === this.$loggingLevels.info) { | ||
if (pid) { | ||
return data && data.indexOf("[" + pid + "]") !== -1 ? data.trim() : null; | ||
} | ||
var matchingInfoMessage = data.match(IOSLogFilter.INFO_FILTER_REGEX); | ||
@@ -11,0 +14,0 @@ return matchingInfoMessage ? matchingInfoMessage[2] : null; |
@@ -13,3 +13,3 @@ "use strict"; | ||
__extends(IOSSimulatorApplicationManager, _super); | ||
function IOSSimulatorApplicationManager(iosSim, identifier, $options, $fs, $bplistParser, $logger) { | ||
function IOSSimulatorApplicationManager(iosSim, identifier, $options, $fs, $bplistParser, $iOSSimulatorLogProvider, $deviceLogProvider, $logger) { | ||
_super.call(this, $logger); | ||
@@ -21,2 +21,4 @@ this.iosSim = iosSim; | ||
this.$bplistParser = $bplistParser; | ||
this.$iOSSimulatorLogProvider = $iOSSimulatorLogProvider; | ||
this.$deviceLogProvider = $deviceLogProvider; | ||
} | ||
@@ -49,3 +51,5 @@ IOSSimulatorApplicationManager.prototype.getInstalledApplications = function () { | ||
if (!_this.$options.justlaunch) { | ||
_this.iosSim.printDeviceLog(_this.identifier, launchResult); | ||
var pid = launchResult.split(":")[1].trim(); | ||
_this.$deviceLogProvider.setApplictionPidForDevice(_this.identifier, pid); | ||
_this.$iOSSimulatorLogProvider.startLogProcess(_this.identifier); | ||
} | ||
@@ -52,0 +56,0 @@ }).future()(); |
@@ -6,3 +6,3 @@ "use strict"; | ||
var IOSSimulator = (function () { | ||
function IOSSimulator(simulator, $devicePlatformsConstants, $injector, $iOSSimResolver) { | ||
function IOSSimulator(simulator, $devicePlatformsConstants, $injector, $iOSSimResolver, $iOSSimulatorLogProvider) { | ||
this.simulator = simulator; | ||
@@ -12,2 +12,3 @@ this.$devicePlatformsConstants = $devicePlatformsConstants; | ||
this.$iOSSimResolver = $iOSSimResolver; | ||
this.$iOSSimulatorLogProvider = $iOSSimulatorLogProvider; | ||
} | ||
@@ -63,3 +64,3 @@ Object.defineProperty(IOSSimulator.prototype, "deviceInfo", { | ||
IOSSimulator.prototype.openDeviceLogStream = function () { | ||
return this.$iOSSimResolver.iOSSim.printDeviceLog(this.deviceInfo.identifier); | ||
this.$iOSSimulatorLogProvider.startLogProcess(this.simulator.id); | ||
}; | ||
@@ -66,0 +67,0 @@ return IOSSimulator; |
@@ -21,6 +21,6 @@ "use strict"; | ||
}); | ||
LogFilter.prototype.filterData = function (platform, data, logLevel) { | ||
LogFilter.prototype.filterData = function (platform, data, pid, logLevel) { | ||
var deviceLogFilter = this.getDeviceLogFilterInstance(platform); | ||
if (deviceLogFilter) { | ||
return deviceLogFilter.filterData(data, logLevel || this.loggingLevel); | ||
return deviceLogFilter.filterData(data, logLevel || this.loggingLevel, pid); | ||
} | ||
@@ -27,0 +27,0 @@ return data; |
@@ -12,6 +12,6 @@ "use strict"; | ||
__extends(IOSSimulatorDiscovery, _super); | ||
function IOSSimulatorDiscovery($childProcess, $injector, $iOSSimResolver, $hostInfo) { | ||
function IOSSimulatorDiscovery($injector, $childProcess, $iOSSimResolver, $hostInfo) { | ||
_super.call(this); | ||
this.$injector = $injector; | ||
this.$childProcess = $childProcess; | ||
this.$injector = $injector; | ||
this.$iOSSimResolver = $iOSSimResolver; | ||
@@ -25,4 +25,7 @@ this.$hostInfo = $hostInfo; | ||
if (this.$hostInfo.isDarwin) { | ||
var currentSimulator = null; | ||
if (this.isSimulatorRunning().wait()) { | ||
var currentSimulator = this.$iOSSimResolver.iOSSim.getRunningSimulator(); | ||
currentSimulator = this.$iOSSimResolver.iOSSim.getRunningSimulator(); | ||
} | ||
if (currentSimulator) { | ||
if (!this.cachedSimulator) { | ||
@@ -29,0 +32,0 @@ this.createAndAddDevice(currentSimulator); |
@@ -5,3 +5,3 @@ "use strict"; | ||
var Wp8EmulatorServices = (function () { | ||
function Wp8EmulatorServices($logger, $emulatorSettingsService, $errors, $childProcess, $devicePlatformsConstants, $hostInfo) { | ||
function Wp8EmulatorServices($logger, $emulatorSettingsService, $errors, $childProcess, $devicePlatformsConstants, $hostInfo, $fs) { | ||
this.$logger = $logger; | ||
@@ -13,3 +13,11 @@ this.$emulatorSettingsService = $emulatorSettingsService; | ||
this.$hostInfo = $hostInfo; | ||
this.$fs = $fs; | ||
} | ||
Object.defineProperty(Wp8EmulatorServices, "programFilesPath", { | ||
get: function () { | ||
return (process.arch === "x64") ? process.env["PROGRAMFILES(X86)"] : process.env.ProgramFiles; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Wp8EmulatorServices.prototype.getEmulatorId = function () { | ||
@@ -24,2 +32,5 @@ return future.fromResult(""); | ||
return (function () { | ||
if (!_this.$fs.exists(_this.getPathToEmulatorStarter()).wait()) { | ||
_this.$errors.failWithoutHelp("You do not have Windows Phone 8 SDK installed. Please install it in order to continue."); | ||
} | ||
if (!_this.$hostInfo.isWindows) { | ||
@@ -41,13 +52,9 @@ _this.$errors.fail("Windows Phone Emulator is available only on Windows 8 or later."); | ||
_this.$logger.info("Starting Windows Phone Emulator"); | ||
var emulatorStarter = path.join(Wp8EmulatorServices.programFilesPath, Wp8EmulatorServices.WP8_LAUNCHER_PATH, Wp8EmulatorServices.WP8_LAUNCHER); | ||
var emulatorStarter = _this.getPathToEmulatorStarter(); | ||
_this.$childProcess.spawn(emulatorStarter, ["/installlaunch", app, "/targetdevice:xd"], { stdio: "ignore", detached: true }).unref(); | ||
}).future()(); | ||
}; | ||
Object.defineProperty(Wp8EmulatorServices, "programFilesPath", { | ||
get: function () { | ||
return (process.arch === "x64") ? process.env["PROGRAMFILES(X86)"] : process.env.ProgramFiles; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Wp8EmulatorServices.prototype.getPathToEmulatorStarter = function () { | ||
return path.join(Wp8EmulatorServices.programFilesPath, Wp8EmulatorServices.WP8_LAUNCHER_PATH, Wp8EmulatorServices.WP8_LAUNCHER); | ||
}; | ||
Wp8EmulatorServices.WP8_LAUNCHER = "XapDeployCmd.exe"; | ||
@@ -54,0 +61,0 @@ Wp8EmulatorServices.WP8_LAUNCHER_PATH = "Microsoft SDKs\\Windows Phone\\v8.0\\Tools\\XAP Deployment"; |
"use strict"; | ||
var util = require("util"); | ||
var helpers = require("./helpers"); | ||
@@ -23,3 +22,13 @@ var yargs = require("yargs"); | ||
this.optionsWhiteList = ["ui", "recursive", "reporter", "require", "timeout", "_", "$0"]; | ||
_.extend(this.options, this.commonOptions, OptionsBase.GLOBAL_OPTIONS); | ||
this.globalOptions = { | ||
log: { type: OptionType.String }, | ||
verbose: { type: OptionType.Boolean, alias: "v" }, | ||
version: { type: OptionType.Boolean }, | ||
help: { type: OptionType.Boolean, alias: "h" }, | ||
profileDir: { type: OptionType.String, default: this.defaultProfileDir }, | ||
analyticsClient: { type: OptionType.String }, | ||
path: { type: OptionType.String, alias: "p" }, | ||
_: { type: OptionType.String } | ||
}; | ||
_.extend(this.options, this.commonOptions, this.globalOptions); | ||
this.setArgv(); | ||
@@ -44,2 +53,3 @@ } | ||
return { | ||
all: { type: OptionType.Boolean }, | ||
json: { type: OptionType.Boolean }, | ||
@@ -92,3 +102,3 @@ watch: { type: OptionType.Boolean }, | ||
if (commandSpecificDashedOptions) { | ||
this.options = OptionsBase.GLOBAL_OPTIONS; | ||
this.options = this.globalOptions; | ||
_.extend(this.options, commandSpecificDashedOptions); | ||
@@ -110,4 +120,3 @@ this.setArgv(); | ||
} | ||
var optionType = _this.getOptionType(optionName); | ||
var optionValue = parsed[optionName]; | ||
var optionType = _this.getOptionType(optionName), optionValue = parsed[optionName]; | ||
if (_.isArray(optionValue) && optionType !== OptionType.Array) { | ||
@@ -126,3 +135,3 @@ _this.$errors.fail("You have set the %s option multiple times. Check the correct command syntax below and try again.", originalOptionName); | ||
OptionsBase.prototype.getCorrectOptionName = function (optionName) { | ||
var secondaryOptionName = this.getSecondaryOptionName(optionName); | ||
var secondaryOptionName = this.getNonDashedOptionName(optionName); | ||
return _.includes(this.optionNames, secondaryOptionName) ? secondaryOptionName : optionName; | ||
@@ -145,16 +154,28 @@ }; | ||
}; | ||
OptionsBase.prototype.getSecondaryOptionName = function (optionName) { | ||
var matchUpperCaseLetters = optionName.match(/(.+?)([-])([a-zA-Z])(.*)/); | ||
OptionsBase.prototype.getNonDashedOptionName = function (optionName) { | ||
var matchUpperCaseLetters = optionName.match(OptionsBase.NONDASHED_OPTION_REGEX); | ||
if (matchUpperCaseLetters) { | ||
var secondaryOptionName = util.format("%s%s%s", matchUpperCaseLetters[1], matchUpperCaseLetters[3].toUpperCase(), matchUpperCaseLetters[4] || ''); | ||
return this.getSecondaryOptionName(secondaryOptionName); | ||
var secondaryOptionName = matchUpperCaseLetters[1] + matchUpperCaseLetters[2].toUpperCase() + matchUpperCaseLetters[3] || ''; | ||
return this.getNonDashedOptionName(secondaryOptionName); | ||
} | ||
return optionName; | ||
}; | ||
OptionsBase.prototype.getDashedOptionName = function (optionName) { | ||
var matchUpperCaseLetters = optionName.match(OptionsBase.DASHED_OPTION_REGEX); | ||
if (matchUpperCaseLetters) { | ||
var secondaryOptionName = matchUpperCaseLetters[1] + "-" + matchUpperCaseLetters[2].toLowerCase() + (matchUpperCaseLetters[3] || ''); | ||
return this.getDashedOptionName(secondaryOptionName); | ||
} | ||
return optionName; | ||
}; | ||
OptionsBase.prototype.setArgv = function () { | ||
this.argv = yargs(process.argv.slice(2)).options(this.options).argv; | ||
var _this = this; | ||
var opts = {}; | ||
_.each(this.options, function (value, key) { | ||
opts[_this.getDashedOptionName(key)] = value; | ||
}); | ||
this.argv = yargs(process.argv.slice(2)).options(opts).argv; | ||
this.adjustDashedOptions(); | ||
}; | ||
OptionsBase.prototype.adjustDashedOptions = function () { | ||
this.argv["profileDir"] = this.argv["profileDir"] || this.defaultProfileDir; | ||
_.each(this.optionNames, function (optionName) { | ||
@@ -172,14 +193,6 @@ Object.defineProperty(OptionsBase.prototype, optionName, { | ||
}; | ||
OptionsBase.GLOBAL_OPTIONS = { | ||
log: { type: OptionType.String }, | ||
verbose: { type: OptionType.Boolean, alias: "v" }, | ||
version: { type: OptionType.Boolean }, | ||
help: { type: OptionType.Boolean, alias: "h" }, | ||
profileDir: { type: OptionType.String }, | ||
analyticsClient: { type: OptionType.String }, | ||
path: { type: OptionType.String, alias: "p" }, | ||
_: { type: OptionType.String } | ||
}; | ||
OptionsBase.DASHED_OPTION_REGEX = /(.+?)([A-Z])(.*)/; | ||
OptionsBase.NONDASHED_OPTION_REGEX = /(.+?)[-]([a-zA-Z])(.*)/; | ||
return OptionsBase; | ||
}()); | ||
exports.OptionsBase = OptionsBase; |
{ | ||
"name": "mobile-cli-lib", | ||
"preferGlobal": false, | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"author": "Telerik <support@telerik.com>", | ||
@@ -36,4 +36,4 @@ "description": "common lib used by different CLI", | ||
"esprima": "2.7.0", | ||
"ffi": "https://github.com/icenium/node-ffi/tarball/v2.0.0.2", | ||
"fibers": "https://github.com/Icenium/node-fibers/tarball/v1.0.13.0", | ||
"ffi": "https://github.com/icenium/node-ffi/tarball/v2.0.0.4", | ||
"fibers": "https://github.com/Icenium/node-fibers/tarball/v1.0.15.0", | ||
"filesize": "2.0.3", | ||
@@ -43,3 +43,3 @@ "gaze": "1.0.0", | ||
"inquirer": "0.8.2", | ||
"ios-sim-portable": "~1.1.4", | ||
"ios-sim-portable": "~1.6.0", | ||
"lodash": "4.13.1", | ||
@@ -54,4 +54,6 @@ "log4js": "0.6.9", | ||
"node-uuid": "1.4.1", | ||
"npm": "3.10.5", | ||
"open": "0.0.4", | ||
"osenv": "0.1.0", | ||
"parse5": "2.2.0", | ||
"plist": "1.1.0", | ||
@@ -62,4 +64,4 @@ "plistlib": "0.2.1", | ||
"pullstream": "https://github.com/icenium/node-pullstream/tarball/master", | ||
"ref": "https://github.com/icenium/ref/tarball/v1.3.2.0", | ||
"ref-struct": "https://github.com/telerik/ref-struct/tarball/v1.0.2.2", | ||
"ref": "https://github.com/icenium/ref/tarball/v1.3.2.2", | ||
"ref-struct": "https://github.com/telerik/ref-struct/tarball/v1.0.2.4", | ||
"rimraf": "2.2.6", | ||
@@ -73,3 +75,3 @@ "semver": "4.3.4", | ||
"xmlhttprequest": "https://github.com/telerik/node-XMLHttpRequest/tarball/master", | ||
"yargs": "4.7.1", | ||
"yargs": "6.0.0", | ||
"zipstream": "https://github.com/Icenium/node-zipstream/tarball/master" | ||
@@ -85,4 +87,4 @@ }, | ||
"grunt-shell": "1.3.0", | ||
"grunt-ts": "5.5.1", | ||
"grunt-tslint": "3.1.0", | ||
"grunt-ts": "6.0.0-beta.3", | ||
"grunt-tslint": "3.3.0", | ||
"istanbul": "0.3.17", | ||
@@ -92,4 +94,4 @@ "mocha": "2.5.3", | ||
"spec-xunit-file": "0.0.1-3", | ||
"tslint": "3.11.0", | ||
"typescript": "1.8.10" | ||
"tslint": "3.15.1", | ||
"typescript": "2.0.7" | ||
}, | ||
@@ -99,5 +101,5 @@ "bundledDependencies": [], | ||
"engines": { | ||
"node": ">=0.12.7 <0.13.0 || >=4.2.1 <5.0.0 || >=5.1.0 <7.0.0" | ||
"node": ">=4.2.1 <5.0.0 || >=5.1.0 <8.0.0" | ||
}, | ||
"buildVersion": "233" | ||
"buildVersion": "300" | ||
} |
@@ -10,6 +10,2 @@ "use strict"; | ||
this.muteStreamInstance = null; | ||
prompt.message = ""; | ||
prompt.delimiter = ":"; | ||
prompt.colors = false; | ||
prompt.isDefaultValueEditable = true; | ||
} | ||
@@ -16,0 +12,0 @@ Prompter.prototype.dispose = function () { |
138
README.md
@@ -10,5 +10,5 @@ mobile-cli-lib | ||
Latest version: 0.20.0 | ||
Latest version: 0.21.0 | ||
Release date: 2016, Aug 17 | ||
Release date: 2016, November 10 | ||
@@ -965,2 +965,136 @@ ### System Requirements | ||
### Module typeScriptService | ||
> Stability: 1 - Could be changed due to some new requirments. | ||
This module is used to transpile TypeScript files. | ||
The following types are used: | ||
```TypeScript | ||
interface ITypeScriptCompilerOptions { | ||
/** | ||
* Specify the codepage to use when opening source files. | ||
*/ | ||
codePage?: number; | ||
/** | ||
* Generates corresponding .d.ts file. | ||
*/ | ||
declaration?: boolean; | ||
/** | ||
* Specifies the location where debugger should locate map files instead of generated locations. | ||
*/ | ||
mapRoot?: string; | ||
/** | ||
* Specify module code generation: 'commonjs' or 'amd'. | ||
*/ | ||
module?: string; | ||
/** | ||
* Warn on expressions and declarations with an implied 'any' type. | ||
*/ | ||
noImplicitAny?: boolean; | ||
/** | ||
* Concatenate and emit output to single file. | ||
*/ | ||
outFile?: string; | ||
/** | ||
* Redirect output structure to the directory. | ||
*/ | ||
outDir?: string; | ||
/** | ||
* Do not emit comments to output. | ||
*/ | ||
removeComments?: boolean; | ||
/** | ||
* Generates corresponding .map file. | ||
*/ | ||
sourceMap?: boolean; | ||
/** | ||
* Specifies the location where debugger should locate TypeScript files instead of source locations. | ||
*/ | ||
sourceRoot?: string; | ||
/** | ||
* Specify ECMAScript target version: 'ES3' (default), or 'ES5'. | ||
*/ | ||
target?: string; | ||
/** | ||
* Do not emit outputs if any errors were reported. | ||
*/ | ||
noEmitOnError?: boolean; | ||
[key: string]: any; | ||
} | ||
/** | ||
* Describes the options for transpiling TypeScript files. | ||
*/ | ||
interface ITypeScriptTranspileOptions { | ||
/** | ||
* Describes the options in tsconfig.json file. | ||
*/ | ||
compilerOptions?: ITypeScriptCompilerOptions; | ||
/** | ||
* The default options which will be used if there is no tsconfig.json file. | ||
*/ | ||
defaultCompilerOptions?: ITypeScriptCompilerOptions; | ||
/** | ||
* Path to the default .d.ts files. | ||
*/ | ||
pathToDefaultDefinitionFiles?: string; | ||
} | ||
``` | ||
* `transpile(projectDir: string, typeScriptFiles?: string[], definitionFiles?: string[], options?: ITypeScriptTranspileOptions): Promise<string>` - Transpiles specified files or all files in the project directory. | ||
If `options` are not specified the method will search for tsconfig.json file and get them from it. | ||
If there is no tsconfig.json file the method will use default options. | ||
If there are no `typeScriptFiles` all the files in the `projectDir` will be transpiled. | ||
The returned result is the output of the TypeScript compiler. | ||
Sample usage: | ||
```JavaScript | ||
// Transpile only 2 files. | ||
var projectDir = "D:\\test\\project"; | ||
var filesToTranspile = [path.join(projectDir,"app","components", "homeView", "homeView.ts"), | ||
path.join(projectDir,"app","components", "addressView", "addressView.ts")]; | ||
require("mobile-cli-lib").typeScriptService.transpile(projectDir, filesToTranspile) | ||
.then(function(result) { | ||
console.log("TypeScript compiler result: ", result); | ||
}).catch(function(err) { | ||
console.log("Error while transpiling files: ", err); | ||
}); | ||
``` | ||
Sample result if there are no errors will be: | ||
```JSON | ||
"" | ||
``` | ||
Sample result with errors will be: | ||
```JSON | ||
"app/components/homeView/homeView.ts(19,1): error TS2304: Cannot find name 'a'. | ||
app/components/homeView/homeView.ts(20,1): error TS2304: Cannot find name 'b'." | ||
``` | ||
```JavaScript | ||
// Transpile all files in project. | ||
require("mobile-cli-lib").typeScriptService.transpile("D:\\test\\project") | ||
.then(function(result) { | ||
console.log("TypeScript compiler result: ", result); | ||
}).catch(function(err) { | ||
console.log("Error while transpiling files: ", err); | ||
}); | ||
``` | ||
Technical details | ||
@@ -967,0 +1101,0 @@ == |
"use strict"; | ||
var helpers = require("../helpers"); | ||
var os = require("os"); | ||
var Future = require("fibers/future"); | ||
@@ -8,3 +7,3 @@ global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; | ||
var AnalyticsServiceBase = (function () { | ||
function AnalyticsServiceBase($logger, $options, $staticConfig, $errors, $prompter, $userSettingsService, $analyticsSettingsService, $progressIndicator) { | ||
function AnalyticsServiceBase($logger, $options, $staticConfig, $errors, $prompter, $userSettingsService, $analyticsSettingsService, $progressIndicator, $osInfo) { | ||
this.$logger = $logger; | ||
@@ -18,2 +17,3 @@ this.$options = $options; | ||
this.$progressIndicator = $progressIndicator; | ||
this.$osInfo = $osInfo; | ||
this.analyticsStatuses = {}; | ||
@@ -219,8 +219,8 @@ this.isAnalyticsStatusesInitialized = false; | ||
var userAgentString; | ||
var osType = os.type(); | ||
var osType = this.$osInfo.type(); | ||
if (osType === "Windows_NT") { | ||
userAgentString = "(Windows NT " + os.release() + ")"; | ||
userAgentString = "(Windows NT " + this.$osInfo.release() + ")"; | ||
} | ||
else if (osType === "Darwin") { | ||
userAgentString = "(Mac OS X " + os.release() + ")"; | ||
userAgentString = "(Mac OS X " + this.$osInfo.release() + ")"; | ||
} | ||
@@ -227,0 +227,0 @@ else { |
"use strict"; | ||
var path = require("path"); | ||
var util = require("util"); | ||
var helpers_1 = require("../helpers"); | ||
var Future = require("fibers/future"); | ||
@@ -24,2 +25,9 @@ var Hook = (function () { | ||
} | ||
Object.defineProperty(HooksService.prototype, "hookArgsName", { | ||
get: function () { | ||
return "hookArgs"; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
HooksService.prototype.initialize = function () { | ||
@@ -89,2 +97,8 @@ this.cachedHooks = {}; | ||
var hookEntryPoint = require(hook.fullPath); | ||
_this.$logger.trace("Validating " + hookName + " arguments."); | ||
var invalidArguments = _this.validateHookArguments(hookEntryPoint); | ||
if (invalidArguments.length) { | ||
_this.$logger.warn(hookName + " will NOT be executed because it has invalid arguments - " + invalidArguments.join(", ").grey + "."); | ||
return; | ||
} | ||
var maybePromise = _this.$injector.resolve(hookEntryPoint, hookArguments); | ||
@@ -208,2 +222,19 @@ if (maybePromise) { | ||
}; | ||
HooksService.prototype.validateHookArguments = function (hookConstructor) { | ||
var _this = this; | ||
var invalidArguments = []; | ||
helpers_1.annotate(hookConstructor); | ||
_.each(hookConstructor.$inject.args, function (argument) { | ||
try { | ||
if (argument !== _this.hookArgsName) { | ||
_this.$injector.resolve(argument); | ||
} | ||
} | ||
catch (err) { | ||
_this.$logger.trace("Cannot resolve " + argument + ", reason: " + err); | ||
invalidArguments.push(argument); | ||
} | ||
}); | ||
return invalidArguments; | ||
}; | ||
HooksService.HOOKS_DIRECTORY_NAME = "hooks"; | ||
@@ -210,0 +241,0 @@ return HooksService; |
@@ -147,3 +147,3 @@ "use strict"; | ||
return function (device, localToDevicePaths) { | ||
var platformLiveSyncService = _this.resolvePlatformLiveSyncService(data.platform, device); | ||
var platformLiveSyncService = _this.resolveDeviceLiveSyncService(data.platform, device); | ||
return platformLiveSyncService.removeFiles(data.appIdentifier, localToDevicePaths); | ||
@@ -163,3 +163,3 @@ }; | ||
if (deviceAppData.isLiveSyncSupported().wait()) { | ||
var platformLiveSyncService = _this.resolvePlatformLiveSyncService(platform, device); | ||
var platformLiveSyncService = _this.resolveDeviceLiveSyncService(platform, device); | ||
if (platformLiveSyncService.beforeLiveSyncAction) { | ||
@@ -255,4 +255,4 @@ platformLiveSyncService.beforeLiveSyncAction(deviceAppData).wait(); | ||
}; | ||
LiveSyncServiceBase.prototype.resolvePlatformLiveSyncService = function (platform, device) { | ||
return this.$injector.resolve(this.$liveSyncProvider.platformSpecificLiveSyncServices[platform.toLowerCase()], { _device: device }); | ||
LiveSyncServiceBase.prototype.resolveDeviceLiveSyncService = function (platform, device) { | ||
return this.$injector.resolve(this.$liveSyncProvider.deviceSpecificLiveSyncServices[platform.toLowerCase()], { _device: device }); | ||
}; | ||
@@ -259,0 +259,0 @@ LiveSyncServiceBase.prototype.getCanExecuteAction = function (platform, appIdentifier, canExecute) { |
@@ -16,4 +16,5 @@ "use strict"; | ||
var _this = this; | ||
var filteredFiles = this.syncQueue.filter(function (syncFile) { return !_this.$projectFilesManager.isFileExcluded(syncFile); }); | ||
return filteredFiles; | ||
var filteredFiles = _.remove(this.syncQueue, function (syncFile) { return _this.$projectFilesManager.isFileExcluded(syncFile); }); | ||
this.$logger.trace("Removed files from syncQueue: ", filteredFiles); | ||
return this.syncQueue; | ||
}, | ||
@@ -20,0 +21,0 @@ enumerable: true, |
"use strict"; | ||
var ProcessService = (function () { | ||
function ProcessService() { | ||
var _this = this; | ||
this._listeners = []; | ||
_.each(ProcessService.PROCESS_EXIT_SIGNALS, function (signal) { | ||
process.on(signal, function () { return _this.executeAllCallbacks.apply(_this); }); | ||
}); | ||
} | ||
@@ -18,3 +14,9 @@ Object.defineProperty(ProcessService.prototype, "listenersCount", { | ||
ProcessService.prototype.attachToProcessExitSignals = function (context, callback) { | ||
var _this = this; | ||
var callbackToString = callback.toString(); | ||
if (this._listeners.length === 0) { | ||
_.each(ProcessService.PROCESS_EXIT_SIGNALS, function (signal) { | ||
process.on(signal, function () { return _this.executeAllCallbacks.apply(_this); }); | ||
}); | ||
} | ||
if (!_.some(this._listeners, function (listener) { return context === listener.context && callbackToString === listener.callback.toString(); })) { | ||
@@ -21,0 +23,0 @@ this._listeners.push({ context: context, callback: callback }); |
@@ -65,10 +65,12 @@ "use strict"; | ||
var extension = path.extname(projectFileInfo.onDeviceFileName); | ||
if ((extension === ".js" || extension === ".map") && onDeviceFilePath !== filePath) { | ||
var oldName = extension === ".map" ? _this.getFileName(filePath, extension) : path.basename(filePath); | ||
var newName = extension === ".map" ? _this.getFileName(projectFileInfo.onDeviceFileName, extension) : path.basename(projectFileInfo.onDeviceFileName); | ||
var fileContent = _this.$fs.readText(filePath).wait(); | ||
fileContent = fileContent.replace(new RegExp(oldName, 'g'), newName); | ||
_this.$fs.writeFile(filePath, fileContent).wait(); | ||
if (onDeviceFilePath !== filePath) { | ||
if (extension === ".js" || extension === ".map") { | ||
var oldName = extension === ".map" ? _this.getFileName(filePath, extension) : path.basename(filePath); | ||
var newName = extension === ".map" ? _this.getFileName(projectFileInfo.onDeviceFileName, extension) : path.basename(projectFileInfo.onDeviceFileName); | ||
var fileContent = _this.$fs.readText(filePath).wait(); | ||
fileContent = fileContent.replace(new RegExp(oldName, 'g'), newName); | ||
_this.$fs.writeFile(filePath, fileContent).wait(); | ||
} | ||
_this.$fs.rename(filePath, onDeviceFilePath).wait(); | ||
} | ||
_this.$fs.rename(filePath, onDeviceFilePath).wait(); | ||
} | ||
@@ -75,0 +77,0 @@ }); |
@@ -39,3 +39,3 @@ "use strict"; | ||
}); | ||
_this.$fs.writeJson(_this.userSettingsFilePath, _this.userSettingsData, "\t").wait(); | ||
_this.$fs.writeJson(_this.userSettingsFilePath, _this.userSettingsData).wait(); | ||
}).future()(); | ||
@@ -42,0 +42,0 @@ }; |
@@ -9,2 +9,3 @@ "use strict"; | ||
var host_info_1 = require("../../host-info"); | ||
var os_info_1 = require("../../os-info"); | ||
var assert = require("chai").assert; | ||
@@ -113,2 +114,3 @@ var trackedFeatureNamesAndValues = ""; | ||
testInjector.register("hostInfo", host_info_1.HostInfo); | ||
testInjector.register("osInfo", os_info_1.OsInfo); | ||
testInjector.register("userSettingsService", new UserSettingsServiceStub(testScenario.featureTracking, testScenario.exceptionsTracking, testInjector)); | ||
@@ -456,4 +458,5 @@ testInjector.register("progressIndicator", { | ||
var testInjector; | ||
var osType = os.type; | ||
var osRelease = os.release; | ||
var osInfo; | ||
var osType; | ||
var osRelease; | ||
var release = "1.0"; | ||
@@ -463,10 +466,13 @@ beforeEach(function () { | ||
service = testInjector.resolve("analyticsService"); | ||
osInfo = testInjector.resolve("osInfo"); | ||
osType = osInfo.type; | ||
osRelease = osInfo.release; | ||
}); | ||
after(function () { | ||
os.type = osType; | ||
os.release = osRelease; | ||
afterEach(function () { | ||
osInfo.type = osType; | ||
osInfo.release = osRelease; | ||
}); | ||
it("sets correct userAgent on Windows", function () { | ||
os.type = function () { return "Windows_NT"; }; | ||
os.release = function () { return release; }; | ||
osInfo.type = function () { return "Windows_NT"; }; | ||
osInfo.release = function () { return release; }; | ||
service.track(name, featureName).wait(); | ||
@@ -476,4 +482,4 @@ assert.equal(lastUsedEqatecSettings.userAgent, "(Windows NT " + release + ")"); | ||
it("sets correct userAgent on MacOS", function () { | ||
os.type = function () { return "Darwin"; }; | ||
os.release = function () { return release; }; | ||
osInfo.type = function () { return "Darwin"; }; | ||
osInfo.release = function () { return release; }; | ||
service.track(name, featureName).wait(); | ||
@@ -483,4 +489,4 @@ assert.equal(lastUsedEqatecSettings.userAgent, "(Mac OS X " + release + ")"); | ||
it("sets correct userAgent on other OSs", function () { | ||
os.type = function () { return "Linux"; }; | ||
os.release = function () { return release; }; | ||
osInfo.type = function () { return "Linux"; }; | ||
osInfo.release = function () { return release; }; | ||
service.track(name, featureName).wait(); | ||
@@ -487,0 +493,0 @@ assert.equal(lastUsedEqatecSettings.userAgent, "(Linux)"); |
@@ -5,2 +5,3 @@ "use strict"; | ||
var device_log_provider_1 = require("../../../appbuilder/device-log-provider"); | ||
var stubs_1 = require("../stubs"); | ||
function createTestInjector(loggingLevel, emptyFilteredData) { | ||
@@ -10,6 +11,7 @@ var testInjector = new yok_1.Yok(); | ||
loggingLevel: loggingLevel, | ||
filterData: function (platform, data, logLevel) { | ||
filterData: function (platform, data, pid, logLevel) { | ||
return emptyFilteredData ? null : logLevel + " " + data; | ||
} | ||
}); | ||
testInjector.register("logger", stubs_1.CommonLoggerStub); | ||
return testInjector; | ||
@@ -16,0 +18,0 @@ } |
@@ -65,6 +65,20 @@ "use strict"; | ||
var options = createOptions(testInjector); | ||
process.argv.pop(); | ||
options.validateOptions(); | ||
chai_1.assert.isTrue(isExecutionStopped); | ||
}); | ||
it("breaks execution when valid dashed option passed without dashes does not have value", function () { | ||
process.argv.push('--someDashedValue'); | ||
var options = createOptions(testInjector); | ||
process.argv.pop(); | ||
options.validateOptions(); | ||
chai_1.assert.isTrue(isExecutionStopped); | ||
}); | ||
it("breaks execution when valid dashed option does not have value", function () { | ||
process.argv.push('--some-dashed-value'); | ||
var options = createOptions(testInjector); | ||
process.argv.pop(); | ||
options.validateOptions(); | ||
chai_1.assert.isTrue(isExecutionStopped); | ||
}); | ||
it("does not break execution when valid option has correct value", function () { | ||
@@ -71,0 +85,0 @@ process.argv.push('--path1'); |
@@ -10,2 +10,3 @@ "use strict"; | ||
var stubs_1 = require("./stubs"); | ||
var Future = require("fibers/future"); | ||
var sampleZipFileTest = path.join(__dirname, "../resources/sampleZipFileTest.zip"); | ||
@@ -20,2 +21,52 @@ var unzippedFileName = "sampleZipFileTest.txt"; | ||
temp.track(); | ||
function createWriteJsonTestCases() { | ||
return [ | ||
{ | ||
exists: true, | ||
text: "{\n\t\"a\" : 5 }", | ||
testCondition: "when the indentation is tab", | ||
expectedIndentation: "\t" | ||
}, { | ||
exists: true, | ||
text: "{\n \"a\" : 5 }", | ||
testCondition: "when the indentation is space", | ||
expectedIndentation: " " | ||
}, { | ||
exists: true, | ||
text: "{\n \"a\" : 5 }", | ||
testCondition: "when the indentation is two spaces", | ||
expectedIndentation: " " | ||
}, { | ||
exists: false, | ||
text: "{\n \"a\" : 5 }", | ||
testCondition: "when the file does not exist", | ||
expectedIndentation: "\t" | ||
}, { | ||
exists: true, | ||
text: "\"just-string\"", | ||
testCondition: "when the the content is string", | ||
expectedIndentation: "\t" | ||
}, { | ||
exists: true, | ||
text: "{ \"a\" : 5 }", | ||
testCondition: "when the content does not have new line after the {", | ||
expectedIndentation: " " | ||
}, { | ||
exists: true, | ||
text: "{\"a\" : 5 }", | ||
testCondition: "when the content is not correctly formatted", | ||
expectedIndentation: "\t" | ||
}, { | ||
exists: true, | ||
text: "{\r\n \"a\" : 5 }", | ||
testCondition: "when the new line is in Windows format", | ||
expectedIndentation: " " | ||
}, { | ||
exists: true, | ||
text: "{\r\n\t\"a\" : 5 }", | ||
testCondition: "when the new line is in Windows format", | ||
expectedIndentation: "\t" | ||
} | ||
]; | ||
} | ||
function createTestInjector() { | ||
@@ -163,2 +214,53 @@ var testInjector = new yok_1.Yok(); | ||
}); | ||
describe("removeEmptyParents", function () { | ||
var testInjector; | ||
var fs; | ||
var notEmptyRootDirectory = path.join("not-empty"); | ||
var removedDirectories; | ||
beforeEach(function () { | ||
testInjector = createTestInjector(); | ||
fs = testInjector.resolve("fs"); | ||
removedDirectories = []; | ||
fs.deleteDirectory = function (directory) { | ||
return (function () { | ||
removedDirectories.push(path.basename(directory)); | ||
}).future()(); | ||
}; | ||
}); | ||
it("should remove all empty parents.", function () { | ||
var emptyDirectories = ["first", "second", "third"]; | ||
var directory = notEmptyRootDirectory; | ||
_.each(emptyDirectories, function (dir) { | ||
directory = path.join(directory, dir); | ||
}); | ||
directory = path.join(directory, "fourth"); | ||
var originalIsEmptyDir = fs.isEmptyDir; | ||
fs.isEmptyDir = function (dirName) { return Future.fromResult(dirName !== notEmptyRootDirectory); }; | ||
fs.deleteEmptyParents(directory).wait(); | ||
fs.isEmptyDir = originalIsEmptyDir; | ||
chai_1.assert.deepEqual(emptyDirectories, _.reverse(removedDirectories)); | ||
}); | ||
}); | ||
describe("writeJson", function () { | ||
var testCases = createWriteJsonTestCases(), testInjector, fs; | ||
beforeEach(function () { | ||
testInjector = createTestInjector(); | ||
fs = testInjector.resolve("fs"); | ||
}); | ||
_.each(testCases, function (testCase) { | ||
it("should use the correct indentation " + testCase.testCondition + ".", function () { | ||
fs.readText = function () { return Future.fromResult(testCase.text); }; | ||
fs.exists = function () { return Future.fromResult(testCase.exists); }; | ||
fs.writeFile = function () { return Future.fromResult(); }; | ||
var actualIndentation; | ||
var originalJsonStringify = JSON.stringify; | ||
JSON.stringify = function (value, replacer, space) { | ||
actualIndentation = space; | ||
}; | ||
fs.writeJson("", testCase.text).wait(); | ||
JSON.stringify = originalJsonStringify; | ||
chai_1.assert.deepEqual(actualIndentation, testCase.expectedIndentation); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -7,56 +7,154 @@ "use strict"; | ||
var iosTestData = [ | ||
{ input: 'Dec 29 08:46:04 Dragons-iPhone iaptransportd[65] <Warning>: CIapPortAppleIDBus: Auth timer timeout completed on pAIDBPort:0x135d09410, portID:01 downstream port', output: null }, | ||
{ input: 'Dec 29 08:46:06 Dragons-iPhone kernel[0] <Notice>: AppleARMPMUCharger: AppleUSBCableDetect 1', output: null }, | ||
{ input: 'Dec 29 08:47:24 Dragons-iPhone bird[131] <Error>: unable to determine evictable space: Error Domain=LibrarianErrorDomain Code=10 "The operation couldn’t be completed. (LibrarianErrorDomain error 10 - Unable to configure the collection.)" UserInfo=0x137528190 {NSDescription=Unable to configure the collection.}', output: null }, | ||
{ input: 'Dec 29 08:47:43 Dragons-iPhone syslog_relay[179] <Notice>: syslog_relay found the ASL prompt. Starting...', output: null }, | ||
{ input: 'Dec 29 08:48:47 Dragons-iPhone com.apple.xpc.launchd[1] (com.apple.WebKit.Networking.08B3A589-3D68-492A-BA8D-A812EC55FDEB[13306]) <Warning>: Service exited with abnormal code: 1', output: null }, | ||
{ input: 'Dec 29 08:48:47 Dragons-iPhone ReportCrash[13308] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/Cordova370_2015-12-29-084847_Dragons-iPhone.ips', output: null }, | ||
{ input: 'Dec 29 08:48:47 Dragons-iPhone com.apple.WebKit.Networking[13306] <Error>: Failed to obtain sandbox extension for path=/private/var/mobile/Containers/Data/Application/047BB8F2-B8C8-405F-A820-8719EE207E6F/Library/Caches/com.telerik.BlankJS. Errno:1', output: null }, | ||
{ input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Apache Cordova native platform version 3.7.0 is starting.', | ||
output: '<Warning>: Apache Cordova native platform version 3.7.0 is starting.' }, | ||
{ input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Notice>: Multi-tasking -> Device: YES, App: YES', output: null }, | ||
{ input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Unlimited access to network resources', | ||
output: '<Warning>: Unlimited access to network resources' }, | ||
{ input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Finished load of: file:///var/mobile/Containers/Data/Application/0746156D-3C83-402E-8B4E-2B3063F42F76/Documents/index.html', | ||
output: '<Warning>: Finished load of: file:///var/mobile/Containers/Data/Application/0746156D-3C83-402E-8B4E-2B3063F42F76/Documents/index.html' }, | ||
{ input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: ---------------------------------- LOG FROM MY APP', | ||
output: '<Warning>: ---------------------------------- LOG FROM MY APP' }, | ||
{ input: 'Dec 29 08:50:31 Dragons-iPhone NativeScript143[13314] <Error>: assertion failed: 12F70: libxpc.dylib + 71768 [B870B51D-AA85-3686-A7D9-ACD48C5FE153]: 0x7d', | ||
output: '<Error>: assertion failed: 12F70: libxpc.dylib + 71768 [B870B51D-AA85-3686-A7D9-ACD48C5FE153]: 0x7d' }, | ||
{ input: 'Dec 29 08:50:31 Dragons-iPhone Unknown[13314] <Error>:', output: null }, | ||
{ input: 'Dec 29 08:50:31 Dragons-iPhone locationd[57] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0', output: null }, | ||
{ input: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13323] <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41', | ||
output: '<Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41' }, | ||
{ input: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13323] <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41\n', | ||
output: '<Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41' } | ||
{ | ||
input: 'Dec 29 08:46:04 Dragons-iPhone iaptransportd[65] <Warning>: CIapPortAppleIDBus: Auth timer timeout completed on pAIDBPort:0x135d09410, portID:01 downstream port', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:46:06 Dragons-iPhone kernel[0] <Notice>: AppleARMPMUCharger: AppleUSBCableDetect 1', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:47:24 Dragons-iPhone bird[131] <Error>: unable to determine evictable space: Error Domain=LibrarianErrorDomain Code=10 "The operation couldn’t be completed. (LibrarianErrorDomain error 10 - Unable to configure the collection.)" UserInfo=0x137528190 {NSDescription=Unable to configure the collection.}', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:47:43 Dragons-iPhone syslog_relay[179] <Notice>: syslog_relay found the ASL prompt. Starting...', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:48:47 Dragons-iPhone com.apple.xpc.launchd[1] (com.apple.WebKit.Networking.08B3A589-3D68-492A-BA8D-A812EC55FDEB[13306]) <Warning>: Service exited with abnormal code: 1', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:48:47 Dragons-iPhone ReportCrash[13308] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/Cordova370_2015-12-29-084847_Dragons-iPhone.ips', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:48:47 Dragons-iPhone com.apple.WebKit.Networking[13306] <Error>: Faild to obtain sandbox extension for path=/private/var/mobile/Containers/Data/Application/047BB8F2-B8C8-405F-A820-8719EE207E6F/Library/Caches/com.telerik.BlankJS. Errno:1', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Apache Cordova native platform version 3.7.0 is starting.', | ||
output: '<Warning>: Apache Cordova native platform version 3.7.0 is starting.', | ||
pid13309Output: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Apache Cordova native platform version 3.7.0 is starting.' | ||
}, | ||
{ | ||
input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Notice>: Multi-tasking -> Device: YES, App: YES', | ||
output: null, | ||
pid13309Output: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Notice>: Multi-tasking -> Device: YES, App: YES' | ||
}, | ||
{ | ||
input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Unlimited access to network resources', | ||
output: '<Warning>: Unlimited access to network resources', | ||
pid13309Output: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Unlimited access to network resources' | ||
}, | ||
{ | ||
input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Finished load of: file:///var/mobile/Containers/Data/Application/0746156D-3C83-402E-8B4E-2B3063F42F76/Documents/index.html', | ||
output: '<Warning>: Finished load of: file:///var/mobile/Containers/Data/Application/0746156D-3C83-402E-8B4E-2B3063F42F76/Documents/index.html', | ||
pid13309Output: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: Finished load of: file:///var/mobile/Containers/Data/Application/0746156D-3C83-402E-8B4E-2B3063F42F76/Documents/index.html', | ||
}, | ||
{ | ||
input: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: ---------------------------------- LOG FROM MY APP', | ||
output: '<Warning>: ---------------------------------- LOG FROM MY APP', | ||
pid13309Output: 'Dec 29 08:49:06 Dragons-iPhone Cordova370[13309] <Warning>: ---------------------------------- LOG FROM MY APP', | ||
}, | ||
{ | ||
input: 'Dec 29 08:50:31 Dragons-iPhone NativeScript143[13314] <Error>: assertion failed: 12F70: libxpc.dylib + 71768 [B870B51D-AA85-3686-A7D9-ACD48C5FE153]: 0x7d', | ||
output: '<Error>: assertion failed: 12F70: libxpc.dylib + 71768 [B870B51D-AA85-3686-A7D9-ACD48C5FE153]: 0x7d', | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:50:31 Dragons-iPhone Unknown[13314] <Error>:', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:50:31 Dragons-iPhone locationd[57] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0', | ||
output: null, | ||
pid13309Output: null | ||
}, | ||
{ | ||
input: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13309] <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41', | ||
output: '<Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41', | ||
pid13309Output: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13309] <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41' | ||
}, | ||
{ | ||
input: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13309] <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41\n', | ||
output: '<Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41', | ||
pid13309Output: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13309] <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41', | ||
}, | ||
{ | ||
input: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13309]: <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41\n', | ||
output: '<Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41', | ||
pid13309Output: 'Dec 29 08:55:24 Dragons-iPhone NativeScript143[13309]: <Notice>: file:///app/main-view-model.js:11:14: CONSOLE LOG COUNTER: 41' | ||
}, | ||
{ | ||
input: 'Oct 4 08:53:46 bd-airtestmac com.apple.CoreSimulator.SimDevice.3616FC55-9CAB-47D4-8C58-5E5F0BE99C8E.launchd_sim[30337] (UIKitApplication:org.nativescript.ap1[0x76c5][13309]): Service exited due to signal: Terminated: 15', | ||
output: null, | ||
pid13309Output: 'Oct 4 08:53:46 bd-airtestmac com.apple.CoreSimulator.SimDevice.3616FC55-9CAB-47D4-8C58-5E5F0BE99C8E.launchd_sim[30337] (UIKitApplication:org.nativescript.ap1[0x76c5][13309]): Service exited due to signal: Terminated: 15' | ||
}, | ||
{ | ||
input: 'Oct 4 08:52:44 bd-airtestmac assertiond[13309]: assertion failed: 15G31 13A344: assertiond + 12188 [93893311-6962-33A7-A734-E36F946D8EBA]: 0x1', | ||
output: null, | ||
pid13309Output: 'Oct 4 08:52:44 bd-airtestmac assertiond[13309]: assertion failed: 15G31 13A344: assertiond + 12188 [93893311-6962-33A7-A734-E36F946D8EBA]: 0x1' | ||
} | ||
]; | ||
describe("iOSLogFilter", function () { | ||
var assertFiltering = function (inputData, expectedOutput, logLevel) { | ||
var assertFiltering = function (inputData, expectedOutput, logLevel, pid) { | ||
var testInjector = new yok_1.Yok(); | ||
testInjector.register("loggingLevels", logging_levels_1.LoggingLevels); | ||
var androidLogFilter = testInjector.resolve(ios_log_filter_1.IOSLogFilter); | ||
var filteredData = androidLogFilter.filterData(inputData, logLevel); | ||
var iOSLogFilter = testInjector.resolve(ios_log_filter_1.IOSLogFilter); | ||
var filteredData = iOSLogFilter.filterData(inputData, logLevel, pid); | ||
assert.deepEqual(filteredData, expectedOutput, "The actual result '" + filteredData + "' did NOT match expected output '" + expectedOutput + "'."); | ||
}; | ||
var logLevel = "INFO"; | ||
var logLevel = "INFO", pid = "13309"; | ||
describe("filterData", function () { | ||
it("when log level is full returns full data", function () { | ||
logLevel = "FULL"; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.input, logLevel); | ||
describe("when PID is not provided", function () { | ||
it("when log level is full returns full data", function () { | ||
logLevel = "FULL"; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.input, logLevel); | ||
}); | ||
}); | ||
}); | ||
it("when log level is INFO filters data", function () { | ||
logLevel = "INFO"; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.output, logLevel); | ||
it("when log level is INFO filters data", function () { | ||
logLevel = "INFO"; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.output, logLevel); | ||
}); | ||
}); | ||
it("when log level is not specified returns full data", function () { | ||
logLevel = null; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.input); | ||
}); | ||
}); | ||
}); | ||
it("when log level is not specified returns full data", function () { | ||
logLevel = null; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.input); | ||
describe("when PID is provided", function () { | ||
it("when log level is full returns full data", function () { | ||
logLevel = "FULL"; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.input, logLevel, pid); | ||
}); | ||
}); | ||
it("when log level is INFO filters data", function () { | ||
logLevel = "INFO"; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.pid13309Output, logLevel, pid); | ||
}); | ||
}); | ||
it("when log level is not specified returns full data", function () { | ||
logLevel = null; | ||
_.each(iosTestData, function (testData) { | ||
assertFiltering(testData.input, testData.input, logLevel, pid); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -14,3 +14,3 @@ "use strict"; | ||
testInjector.register("iOSLogFilter", { | ||
filterData: function (data, logLevel) { | ||
filterData: function (data, logLevel, pid) { | ||
return "ios: " + data + " " + logLevel; | ||
@@ -20,3 +20,3 @@ } | ||
testInjector.register("androidLogFilter", { | ||
filterData: function (data, logLevel) { | ||
filterData: function (data, logLevel, pid) { | ||
return "android: " + data + " " + logLevel; | ||
@@ -88,11 +88,11 @@ } | ||
it("returns same data when platform is not correct", function () { | ||
var actualData = logFilter.filterData("invalidPlatform", testData, logLevel); | ||
var actualData = logFilter.filterData("invalidPlatform", testData, null, logLevel); | ||
assert.deepEqual(actualData, testData, logLevel); | ||
}); | ||
it("returns correct data when platform is android", function () { | ||
var actualData = logFilter.filterData("android", testData, logLevel); | ||
var actualData = logFilter.filterData("android", testData, null, logLevel); | ||
assert.deepEqual(actualData, androidInfoTestData); | ||
}); | ||
it("returns correct data when platform is ios", function () { | ||
var actualData = logFilter.filterData("ios", testData, logLevel); | ||
var actualData = logFilter.filterData("ios", testData, null, logLevel); | ||
assert.deepEqual(actualData, iosInfoTestData); | ||
@@ -104,11 +104,11 @@ }); | ||
it("returns same data when platform is not correct", function () { | ||
var actualData = logFilter.filterData("invalidPlatform", testData, logLevel); | ||
var actualData = logFilter.filterData("invalidPlatform", testData, null, logLevel); | ||
assert.deepEqual(actualData, testData, logLevel); | ||
}); | ||
it("returns correct data when platform is android", function () { | ||
var actualData = logFilter.filterData("android", testData, logLevel); | ||
var actualData = logFilter.filterData("android", testData, null, logLevel); | ||
assert.deepEqual(actualData, androidFullTestData); | ||
}); | ||
it("returns correct data when platform is ios", function () { | ||
var actualData = logFilter.filterData("ios", testData, logLevel); | ||
var actualData = logFilter.filterData("ios", testData, null, logLevel); | ||
assert.deepEqual(actualData, iosFullTestData); | ||
@@ -115,0 +115,0 @@ }); |
@@ -64,2 +64,8 @@ "use strict"; | ||
}()); | ||
function mockFsStats(options) { | ||
return function (filePath) { return Future.fromResult({ | ||
isDirectory: function () { return options.isDirectory; }, | ||
isFile: function () { return options.isFile; } | ||
}); }; | ||
} | ||
function createTestInjector() { | ||
@@ -100,6 +106,3 @@ var injector = new yok_1.Yok(); | ||
fs.exists = function (filePath) { return Future.fromResult(false); }; | ||
fs.getFsStats = function (filePath) { return Future.fromResult({ | ||
isDirectory: function () { return false; }, | ||
isFile: function () { return true; } | ||
}); }; | ||
fs.getFsStats = mockFsStats({ isDirectory: false, isFile: true }); | ||
var androidDeviceFileSystem = createAndroidDeviceFileSystem(injector); | ||
@@ -133,6 +136,4 @@ androidDeviceFileSystem.transferDirectory(deviceAppData, localToDevicePaths, "~/TestApp/app").wait(); | ||
fs.readJson = function (filePath) { return (function () { return ({ "~/TestApp/app/test.js": "0", "~/TestApp/app/myfile.js": "2" }); }).future()(); }; | ||
fs.getFsStats = function (filePath) { return Future.fromResult({ | ||
isDirectory: function () { return false; }, | ||
isFile: function () { return true; } | ||
}); }; | ||
fs.getFsStats = mockFsStats({ isDirectory: false, isFile: true }); | ||
fs.readText = function () { return Future.fromResult(""); }; | ||
var androidDeviceFileSystem = createAndroidDeviceFileSystem(injector); | ||
@@ -158,6 +159,4 @@ androidDeviceFileSystem.transferFile = function (localPath, devicePath) { | ||
fs.readJson = function (filePath) { return (function () { return ({ "~/TestApp/app/test.js": "0", "~/TestApp/app/myfile.js": "4", "~/TestApp/app/notchangedFile.js": "3" }); }).future()(); }; | ||
fs.getFsStats = function (filePath) { return Future.fromResult({ | ||
isDirectory: function () { return false; }, | ||
isFile: function () { return true; } | ||
}); }; | ||
fs.getFsStats = mockFsStats({ isDirectory: false, isFile: true }); | ||
fs.readText = function () { return Future.fromResult(""); }; | ||
var androidDeviceFileSystem = createAndroidDeviceFileSystem(injector); | ||
@@ -187,6 +186,4 @@ var transferedFilesOnDevice = []; | ||
fs.readJson = function (filePath) { return (function () { return ({ "~/TestApp/app/test.js": "0", "~/TestApp/app/myfile.js": "2" }); }).future()(); }; | ||
fs.getFsStats = function (filePath) { return Future.fromResult({ | ||
isDirectory: function () { return false; }, | ||
isFile: function () { return true; } | ||
}); }; | ||
fs.getFsStats = mockFsStats({ isDirectory: false, isFile: true }); | ||
fs.readText = function () { return Future.fromResult(""); }; | ||
var androidDeviceFileSystem = createAndroidDeviceFileSystem(injector); | ||
@@ -211,6 +208,4 @@ androidDeviceFileSystem.transferFile = function (localPath, devicePath) { | ||
fs.readJson = function (filePath) { return (function () { return ({ "~/TestApp/app/test.js": "0", "~/TestApp/app/myfile.js": "2" }); }).future()(); }; | ||
fs.getFsStats = function (filePath) { return Future.fromResult({ | ||
isDirectory: function () { return false; }, | ||
isFile: function () { return true; } | ||
}); }; | ||
fs.getFsStats = mockFsStats({ isDirectory: false, isFile: true }); | ||
fs.readText = function () { return Future.fromResult(""); }; | ||
var androidDeviceFileSystem = createAndroidDeviceFileSystem(injector); | ||
@@ -217,0 +212,0 @@ androidDeviceFileSystem.transferFile = function (localPath, devicePath) { |
@@ -23,8 +23,4 @@ "use strict"; | ||
injector.register("devicePlatformsConstants", device_platforms_constants_1.DevicePlatformsConstants); | ||
injector.register("iOSSimResolver", { | ||
iOSSim: { | ||
getRunningSimulator: function () { return currentlyRunningSimulator; } | ||
} | ||
}); | ||
injector.register("iOSSimulatorDiscovery", ios_simulator_discovery_1.IOSSimulatorDiscovery); | ||
injector.register("iOSSimulatorLogProvider", {}); | ||
return injector; | ||
@@ -46,2 +42,3 @@ } | ||
isCurrentlyRunning = false; | ||
currentlyRunningSimulator = null; | ||
var lostDeviceFuture = new Future(); | ||
@@ -55,3 +52,2 @@ iOSSimulatorDiscovery.once("deviceLost", function (device) { | ||
var detectSimulatorChanged = function (newId) { | ||
isCurrentlyRunning = true; | ||
currentlyRunningSimulator.id = newId; | ||
@@ -75,3 +71,4 @@ var lostDeviceFuture = new Future(), foundDeviceFuture = new Future(); | ||
iOSSimulatorDiscovery = testInjector.resolve("iOSSimulatorDiscovery"); | ||
expectedDeviceInfo = { identifier: "id", | ||
expectedDeviceInfo = { | ||
identifier: "id", | ||
displayName: 'name', | ||
@@ -78,0 +75,0 @@ model: 'c', |
@@ -19,4 +19,4 @@ "use strict"; | ||
var testedApplicationIdentifier = "com.telerik.myApp"; | ||
var iOSDeviceProjectRootPath = "/Library/Application Support/LiveSync/app"; | ||
var iOSDeviceSyncZipPath = "/Library/Application Support/LiveSync/sync.zip"; | ||
var iOSDeviceProjectRootPath = "/Documents/AppBuilder/LiveSync/app"; | ||
var iOSDeviceSyncZipPath = "/Documents/AppBuilder/LiveSync/sync.zip"; | ||
var androidDeviceProjectRootPath = "/data/local/tmp/sync"; | ||
@@ -23,0 +23,0 @@ var IOSAppIdentifierMock = (function () { |
@@ -12,4 +12,4 @@ "use strict"; | ||
} | ||
if (semver.satisfies(nodeVer, "~0.10.0")) { | ||
console.warn((os_1.EOL + "Support for Node.js 0.10.x is deprecated and will be removed in the " + cliName + " " + deprecationVersion + " release. Please, upgrade to the latest Node.js LTS version." + os_1.EOL).yellow.bold); | ||
if (semver.satisfies(nodeVer, "~0.12.0")) { | ||
console.warn((os_1.EOL + "Support for Node.js 0.12.x is deprecated and will be removed in the " + cliName + " " + deprecationVersion + " release. Please, upgrade to the latest Node.js LTS version." + os_1.EOL).yellow.bold); | ||
} | ||
@@ -19,3 +19,3 @@ else { | ||
if (!checkSatisfied) { | ||
console.log((os_1.EOL + "Support for node.js " + nodeVer + " is not verified. This CLI might not install or run properly." + os_1.EOL).yellow.bold); | ||
console.log((os_1.EOL + "Support for Node.js " + nodeVer + " is not verified. This CLI might not install or run properly." + os_1.EOL).yellow.bold); | ||
} | ||
@@ -22,0 +22,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 4 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 4 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9907681
223
21969
1201
11
46
49
+ Addednpm@3.10.5
+ Addedparse5@2.2.0
+ Addedget-caller-file@1.0.3(transitive)
+ Addedios-sim-portable@1.6.2(transitive)
+ Addednpm@3.10.5(transitive)
+ Addedparse5@2.2.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedwhich-module@1.0.0(transitive)
+ Addedyargs@6.0.0(transitive)
+ Addedyargs-parser@4.2.1(transitive)
- Removedios-sim-portable@1.1.4(transitive)
Updatedffi@https://github.com/icenium/node-ffi/tarball/v2.0.0.4
Updatedfibers@https://github.com/Icenium/node-fibers/tarball/v1.0.15.0
Updatedios-sim-portable@~1.6.0
Updatedref-struct@https://github.com/telerik/ref-struct/tarball/v1.0.2.4
Updatedyargs@6.0.0