mobile-cli-lib
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -13,1 +13,2 @@ require("../bootstrap"); | ||
$injector.require("mobilePlatformsCapabilities", "./appbuilder/mobile-platforms-capabilities"); | ||
$injector.requirePublic("npmService", "./appbuilder/services/npm-service"); |
@@ -19,2 +19,3 @@ "use strict"; | ||
this.ADDITIONAL_FILES_DIRECTORY = ".ab"; | ||
this.REFERENCES_FILE_NAME = ".abreferences.d.ts"; | ||
this.APPBUILDER_PROJECT_PLATFORMS_NAMES = { | ||
@@ -21,0 +22,0 @@ android: "Android", |
@@ -19,3 +19,2 @@ "use strict"; | ||
this._hasBuildConfigurations = false; | ||
this.startPackageActivity = constants_2.startPackageActivityNames[constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase()]; | ||
this.configurationSpecificData = Object.create(null); | ||
@@ -59,2 +58,10 @@ } | ||
}); | ||
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", { | ||
@@ -61,0 +68,0 @@ get: function () { |
@@ -8,3 +8,3 @@ "use strict"; | ||
} | ||
Object.defineProperty(AppBuilderLiveSyncProviderBase.prototype, "platformSpecificLiveSyncServices", { | ||
Object.defineProperty(AppBuilderLiveSyncProviderBase.prototype, "deviceSpecificLiveSyncServices", { | ||
get: function () { | ||
@@ -24,2 +24,9 @@ var _this = this; | ||
}); | ||
Object.defineProperty(AppBuilderLiveSyncProviderBase.prototype, "platformSpecificLiveSyncServices", { | ||
get: function () { | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
AppBuilderLiveSyncProviderBase.prototype.preparePlatformForSync = function (platform) { | ||
@@ -26,0 +33,0 @@ return Future.fromResult(); |
@@ -77,2 +77,3 @@ global._ = require("lodash"); | ||
$injector.require("autoCompletionService", "./services/auto-completion-service"); | ||
$injector.require("processService", "./services/process-service"); | ||
$injector.require("opener", "./opener"); | ||
@@ -79,0 +80,0 @@ $injector.require("dynamicHelpService", "./services/dynamic-help-service"); |
@@ -20,4 +20,4 @@ "use strict"; | ||
var client = _this.$staticConfig.CLIENT_NAME_ALIAS || _this.$staticConfig.CLIENT_NAME; | ||
_this.$logger.out(("These warnings are just used to help the " + client + " maintainers with debugging if you file an issue.").bold | ||
+ os_1.EOL + ("Please ignore them if everything you use " + client + " for is working fine.").bold + os_1.EOL); | ||
_this.$logger.out(("When you file an issue, these warnings will help the " + client + " team to investigate, identify, and resolve the report.").bold | ||
+ os_1.EOL + ("Please, ignore them if you are not experiencing any issues with " + client + ".").bold + os_1.EOL); | ||
} | ||
@@ -24,0 +24,0 @@ else { |
@@ -46,1 +46,11 @@ "use strict"; | ||
exports.Configurations = Configurations; | ||
exports.NODE_MODULES_DIR_NAME = "node_modules"; | ||
exports.TNS_CORE_MODULES = "tns-core-modules"; | ||
var FileExtensions = (function () { | ||
function FileExtensions() { | ||
} | ||
FileExtensions.TYPESCRIPT_DEFINITION_FILE = ".d.ts"; | ||
FileExtensions.TYPESCRIPT_FILE = ".ts"; | ||
return FileExtensions; | ||
}()); | ||
exports.FileExtensions = FileExtensions; |
@@ -270,2 +270,29 @@ "use strict"; | ||
exports.connectEventually = connectEventually; | ||
function connectEventuallyUntilTimeout(factory, timeout) { | ||
var future = new Future(); | ||
var lastKnownError; | ||
setTimeout(function () { | ||
if (!future.isResolved()) { | ||
future.throw(lastKnownError); | ||
} | ||
}, timeout); | ||
function tryConnect() { | ||
var tryConnectAfterTimeout = function (error) { | ||
if (future.isResolved()) { | ||
return; | ||
} | ||
lastKnownError = error; | ||
setTimeout(tryConnect, 1000); | ||
}; | ||
var socket = factory(); | ||
socket.on("connect", function () { | ||
socket.removeListener("error", tryConnectAfterTimeout); | ||
future.return(socket); | ||
}); | ||
socket.on("error", tryConnectAfterTimeout); | ||
} | ||
tryConnect(); | ||
return future; | ||
} | ||
exports.connectEventuallyUntilTimeout = connectEventuallyUntilTimeout; | ||
var FN_NAME_AND_ARGS = /^function\s*([^\(]*)\(\s*([^\)]*)\)/m; | ||
@@ -272,0 +299,0 @@ var FN_ARG_SPLIT = /,/; |
@@ -5,3 +5,3 @@ "use strict"; | ||
var LogcatHelper = (function () { | ||
function LogcatHelper($childProcess, $deviceLogProvider, $devicePlatformsConstants, $logger, $injector) { | ||
function LogcatHelper($childProcess, $deviceLogProvider, $devicePlatformsConstants, $logger, $injector, $processService) { | ||
this.$childProcess = $childProcess; | ||
@@ -12,2 +12,3 @@ this.$deviceLogProvider = $deviceLogProvider; | ||
this.$injector = $injector; | ||
this.$processService = $processService; | ||
this.mapDeviceToLoggingStarted = Object.create(null); | ||
@@ -20,8 +21,8 @@ } | ||
adb.executeCommand(["logcat", "-c"]).wait(); | ||
var adbLogcat_1 = adb.executeCommand(["logcat"], { returnChildProcess: true }).wait(); | ||
var lineStream = byline(adbLogcat_1.stdout); | ||
adbLogcat_1.stderr.on("data", function (data) { | ||
var adbLogcat = adb.executeCommand(["logcat"], { returnChildProcess: true }).wait(); | ||
var lineStream = byline(adbLogcat.stdout); | ||
adbLogcat.stderr.on("data", function (data) { | ||
_this.$logger.trace("ADB logcat stderr: " + data.toString()); | ||
}); | ||
adbLogcat_1.on("close", function (code) { | ||
adbLogcat.on("close", function (code) { | ||
try { | ||
@@ -40,7 +41,3 @@ _this.mapDeviceToLoggingStarted[deviceIdentifier] = false; | ||
}); | ||
process.on("exit", function () { | ||
if (adbLogcat_1) { | ||
adbLogcat_1.kill(); | ||
} | ||
}); | ||
this.$processService.attachToProcessExitSignals(this, adbLogcat.kill); | ||
this.mapDeviceToLoggingStarted[deviceIdentifier] = true; | ||
@@ -47,0 +44,0 @@ } |
@@ -65,3 +65,3 @@ "use strict"; | ||
try { | ||
if (_this.isApplicationInstalled(appIdentifier).wait() && _this.canStartApplication()) { | ||
if (_this.canStartApplication()) { | ||
_this.startApplication(appIdentifier, framework).wait(); | ||
@@ -68,0 +68,0 @@ } |
@@ -95,2 +95,5 @@ "use strict"; | ||
} | ||
if (emulatorOptions && emulatorOptions.skipInstall) { | ||
opts.push("--skipInstall"); | ||
} | ||
var stdioOpts = { stdio: (emulatorOptions && emulatorOptions.captureStdin) ? "pipe" : "inherit" }; | ||
@@ -97,0 +100,0 @@ return this.$childProcess.spawn(nodeCommandName, opts, stdioOpts); |
@@ -84,2 +84,5 @@ "use strict"; | ||
return (function () { | ||
if (!_this.isApplicationInstalled(appIdentifier).wait()) { | ||
return null; | ||
} | ||
var applicationPath = _this.iosSim.getApplicationPath(_this.identifier, appIdentifier), pathToInfoPlist = path.join(applicationPath, "Info.plist"); | ||
@@ -86,0 +89,0 @@ return _this.$fs.exists(pathToInfoPlist).wait() ? _this.$bplistParser.parseFile(pathToInfoPlist).wait()[0] : null; |
"use strict"; | ||
var os_1 = require("os"); | ||
var shelljs = require("shelljs"); | ||
var device_android_debug_bridge_1 = require("../android/device-android-debug-bridge"); | ||
var constants_1 = require("../../constants"); | ||
var AndroidProcessService = (function () { | ||
function AndroidProcessService($errors, $staticConfig, $injector, $net) { | ||
function AndroidProcessService($errors, $staticConfig, $injector, $net, $processService) { | ||
this.$errors = $errors; | ||
@@ -11,3 +12,5 @@ this.$staticConfig = $staticConfig; | ||
this.$net = $net; | ||
this.$processService = $processService; | ||
this._devicesAdbs = {}; | ||
this._forwardedLocalPorts = []; | ||
} | ||
@@ -28,2 +31,3 @@ Object.defineProperty(AndroidProcessService.prototype, "androidPortInformationRegExp", { | ||
return (function () { | ||
_this.tryAttachToProcessExitSignals(); | ||
var adb = _this.getAdb(deviceIdentifier); | ||
@@ -45,2 +49,3 @@ var processId = _this.getProcessIds(adb, [appIdentifier]).wait()[appIdentifier]; | ||
} | ||
_this._forwardedLocalPorts.push(localPort); | ||
return localPort; | ||
@@ -202,2 +207,10 @@ }).future()(); | ||
}; | ||
AndroidProcessService.prototype.tryAttachToProcessExitSignals = function () { | ||
var _this = this; | ||
this.$processService.attachToProcessExitSignals(this, function () { | ||
_.each(_this._forwardedLocalPorts, function (port) { | ||
shelljs.exec("adb forward --remove tcp:" + port); | ||
}); | ||
}); | ||
}; | ||
return AndroidProcessService; | ||
@@ -204,0 +217,0 @@ }()); |
@@ -19,3 +19,3 @@ "use strict"; | ||
var DevicesService = (function () { | ||
function DevicesService($logger, $errors, $iOSSimulatorDiscovery, $iOSDeviceDiscovery, $androidDeviceDiscovery, $staticConfig, $messages, $mobileHelper, $deviceLogProvider, $hostInfo, $devicePlatformsConstants, $injector, $options, $androidProcessService) { | ||
function DevicesService($logger, $errors, $iOSSimulatorDiscovery, $iOSDeviceDiscovery, $androidDeviceDiscovery, $staticConfig, $messages, $mobileHelper, $deviceLogProvider, $hostInfo, $devicePlatformsConstants, $injector, $options, $androidProcessService, $processService) { | ||
this.$logger = $logger; | ||
@@ -35,2 +35,3 @@ this.$errors = $errors; | ||
this.$androidProcessService = $androidProcessService; | ||
this.$processService = $processService; | ||
this._devices = {}; | ||
@@ -144,2 +145,3 @@ this.platforms = []; | ||
var _this = this; | ||
this.$processService.attachToProcessExitSignals(this, this.clearDeviceDetectionInterval); | ||
if (this.deviceDetectionInterval) { | ||
@@ -193,10 +195,5 @@ this.$logger.trace("Device detection interval is already started. New Interval will not be started."); | ||
return (function () { | ||
if (_this.deviceDetectionInterval) { | ||
clearInterval(_this.deviceDetectionInterval); | ||
_this.deviceDetectionInterval = null; | ||
_this.clearCurrentDeviceDetectionIntervalFuture().wait(); | ||
} | ||
else { | ||
_this.$logger.trace("Device detection interval is not started, so it cannot be stopped."); | ||
} | ||
_this.clearDeviceDetectionInterval(); | ||
_this.deviceDetectionInterval = null; | ||
_this.getDeviceDetectionIntervalFuture().wait(); | ||
}).future()(); | ||
@@ -409,2 +406,10 @@ }; | ||
}; | ||
DevicesService.prototype.clearDeviceDetectionInterval = function () { | ||
if (this.deviceDetectionInterval) { | ||
clearInterval(this.deviceDetectionInterval); | ||
} | ||
else { | ||
this.$logger.trace("Device detection interval is not started, so it cannot be stopped."); | ||
} | ||
}; | ||
DevicesService.prototype.getDebuggableAppsCore = function (deviceIdentifier) { | ||
@@ -518,3 +523,3 @@ var _this = this; | ||
}; | ||
DevicesService.prototype.clearCurrentDeviceDetectionIntervalFuture = function () { | ||
DevicesService.prototype.getDeviceDetectionIntervalFuture = function () { | ||
return this.deviceDetectionIntervalFuture || Future.fromResult(); | ||
@@ -521,0 +526,0 @@ }; |
{ | ||
"name": "mobile-cli-lib", | ||
"preferGlobal": false, | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"author": "Telerik <support@telerik.com>", | ||
@@ -94,3 +94,3 @@ "description": "common lib used by different CLI", | ||
}, | ||
"buildVersion": "221" | ||
"buildVersion": "233" | ||
} |
@@ -124,3 +124,3 @@ "use strict"; | ||
}); | ||
this.ctrlcReader.on("SIGINT", function () { return process.exit(); }); | ||
this.ctrlcReader.on("SIGINT", process.exit); | ||
} | ||
@@ -132,2 +132,3 @@ }; | ||
if (this.muteStreamInstance) { | ||
this.cleanEventListeners(process.stdout); | ||
this.muteStreamInstance.unmute(); | ||
@@ -139,2 +140,23 @@ this.muteStreamInstance = null; | ||
}; | ||
Prompter.prototype.cleanEventListeners = function (stream) { | ||
var _this = this; | ||
var memoryLeakEvents = [{ | ||
eventName: "close", | ||
listenerName: "cleanup" | ||
}, { | ||
eventName: "error", | ||
listenerName: "onerror" | ||
}, { | ||
eventName: "drain", | ||
listenerName: "ondrain" | ||
}]; | ||
_.each(memoryLeakEvents, function (memoryleakEvent) { return _this.cleanListener(stream, memoryleakEvent.eventName, memoryleakEvent.listenerName); }); | ||
}; | ||
Prompter.prototype.cleanListener = function (stream, eventName, listenerName) { | ||
var eventListeners = process.stdout.listeners(eventName); | ||
var listenerFunction = _.find(eventListeners, function (func) { return func.name === listenerName; }); | ||
if (listenerFunction) { | ||
stream.removeListener(eventName, listenerFunction); | ||
} | ||
}; | ||
return Prompter; | ||
@@ -141,0 +163,0 @@ }()); |
105
README.md
@@ -10,5 +10,5 @@ mobile-cli-lib | ||
Latest version: 0.19.0 | ||
Latest version: 0.20.0 | ||
Release date: 2016, July 19 | ||
Release date: 2016, Aug 17 | ||
@@ -864,2 +864,103 @@ ### System Requirements | ||
### Module npmService | ||
> Stability: 1 - Could be changed due to some new requirments. | ||
This module is used to install or uninstall packages from npm. | ||
The following types are used: | ||
```TypeScript | ||
/** | ||
* Describes information for single npm dependency that has to be installed. | ||
*/ | ||
interface INpmDependency { | ||
/** | ||
* Name of the dependency. | ||
*/ | ||
name: string; | ||
/** | ||
* @optional The version of the dependency that has to be installed. | ||
*/ | ||
version?: string; | ||
/** | ||
* Defines if @types/<name> should be installed as well. | ||
*/ | ||
installTypes: boolean; | ||
} | ||
/** | ||
* Describes the result of npm install command. | ||
*/ | ||
interface INpmInstallResult { | ||
/** | ||
* The result of installing a single dependency. | ||
*/ | ||
result?: INpmInstallDependencyResult, | ||
/** | ||
* The error that occurred during the operation. | ||
*/ | ||
error?: Error; | ||
} | ||
``` | ||
* `install(projectDir: string, dependencyToInstall?: INpmDependency): Promise<INpmInstallResult>` - Installs everything from package.json or specified dependency. | ||
In case there's information which dependency to install, the method will check it and install only this dependency and possibly its @types. | ||
Sample usage: | ||
```JavaScript | ||
// Install all dependencies from package.json. | ||
require("mobile-cli-lib").npmService.install("D:\\test\\project") | ||
.then(function(result) { | ||
console.log("The npm result is: ", result); | ||
}).catch(function(err) { | ||
console.log("Error while installing packages from npm: ", err); | ||
}); | ||
``` | ||
Sample result will be: | ||
```JSON | ||
{} | ||
``` | ||
```JavaScript | ||
// Install specific dependency from npm. | ||
var dependency = { | ||
name: "lodash", | ||
version: "4.15.0", | ||
installTypes: true | ||
}; | ||
require("mobile-cli-lib").npmService.install("D:\\test\\project", dependency) | ||
.then(function(result) { | ||
console.log("The npm result is: ", result); | ||
}).catch(function(err) { | ||
console.log("Error while installing packages from npm: ", err); | ||
}); | ||
``` | ||
Sample result will be: | ||
```JSON | ||
{ | ||
"result": { | ||
"isInstalled": true, | ||
"isTypesInstalled": true | ||
} | ||
} | ||
``` | ||
* `uninstall(projectDir: string, dependency: string): Promise` - Uninstalls the dependency and the @types/<dependency> devDependency. | ||
The method will remove them from package.json and from node_modules dir. | ||
Sample usage: | ||
```JavaScript | ||
require("mobile-cli-lib").npmService.uninstall("D:\\test\\project", "lodash") | ||
.then(function() { | ||
console.log("The dependency is uninstalled."); | ||
}).catch(function(err) { | ||
console.log("Error while uninstalling packages from npm: ", err); | ||
}); | ||
``` | ||
Technical details | ||
@@ -866,0 +967,0 @@ == |
@@ -32,9 +32,2 @@ "use strict"; | ||
} | ||
LiveSyncServiceBase.prototype.getPlatform = function (platform) { | ||
var _this = this; | ||
return (function () { | ||
_this.$devicesService.initialize({ platform: platform, deviceId: _this.$options.device }).wait(); | ||
return platform || _this.$devicesService.platform; | ||
}).future()(); | ||
}; | ||
LiveSyncServiceBase.prototype.sync = function (data, filePaths) { | ||
@@ -234,6 +227,11 @@ var _this = this; | ||
if (canTransferDirectory) { | ||
var tempDir = temp.mkdirSync("tempDir"); | ||
shell.cp("-Rf", path.join(projectFilesPath, "*"), tempDir); | ||
_this.$projectFilesManager.processPlatformSpecificFiles(tempDir, deviceAppData.platform).wait(); | ||
deviceAppData.device.fileSystem.transferDirectory(deviceAppData, localToDevicePaths, tempDir).wait(); | ||
var tempDir_1 = temp.mkdirSync("tempDir"); | ||
_.each(localToDevicePaths, function (localToDevicePath) { | ||
var fileDirname = path.join(tempDir_1, path.dirname(localToDevicePath.getRelativeToProjectBasePath())); | ||
shell.mkdir("-p", fileDirname); | ||
if (!_this.$fs.getFsStats(localToDevicePath.getLocalPath()).wait().isDirectory()) { | ||
shell.cp("-f", localToDevicePath.getLocalPath(), path.join(fileDirname, path.basename(localToDevicePath.getDevicePath()))); | ||
} | ||
}); | ||
deviceAppData.device.fileSystem.transferDirectory(deviceAppData, localToDevicePaths, tempDir_1).wait(); | ||
} | ||
@@ -240,0 +238,0 @@ else { |
@@ -16,2 +16,3 @@ "use strict"; | ||
this.javaVerCache = null; | ||
this.npmVerCache = null; | ||
this.javaCompilerVerCache = null; | ||
@@ -39,2 +40,9 @@ this.xCodeVerCache = null; | ||
}; | ||
SysInfoBase.prototype.getNpmVersion = function () { | ||
if (!this.npmVerCache) { | ||
var procOutput = this.exec("npm -v"); | ||
this.npmVerCache = procOutput ? procOutput.split("\n")[0] : null; | ||
} | ||
return this.npmVerCache; | ||
}; | ||
SysInfoBase.prototype.getJavaCompilerVersion = function () { | ||
@@ -156,4 +164,3 @@ var _this = this; | ||
res.nodeVer = process.version; | ||
procOutput = _this.exec("npm -v"); | ||
res.npmVer = procOutput ? procOutput.split("\n")[0] : null; | ||
res.npmVer = _this.getNpmVersion(); | ||
res.javaVer = _this.getJavaVersion().wait(); | ||
@@ -160,0 +167,0 @@ res.nodeGypVer = _this.getNodeGypVersion().wait(); |
@@ -500,6 +500,5 @@ "use strict"; | ||
describe("tryStartApplication", function () { | ||
it("calls startApplication, when application is installed and canStartApplication returns true", function () { | ||
it("calls startApplication, when canStartApplication returns true", function () { | ||
var startApplicationAppIdParam, startApplicationFrameworkParam; | ||
applicationManager.canStartApplication = function () { return true; }; | ||
applicationManager.isApplicationInstalled = function (appId) { return Future.fromResult(true); }; | ||
applicationManager.startApplication = function (appId, framework) { | ||
@@ -517,17 +516,5 @@ startApplicationAppIdParam = appId; | ||
}); | ||
it("does not call startApplication, when application is NOT installed", function () { | ||
it("does not call startApplication, when canStartApplication returns false", function () { | ||
var isStartApplicationCalled = false; | ||
applicationManager.canStartApplication = function () { return true; }; | ||
applicationManager.isApplicationInstalled = function (appId) { return Future.fromResult(false); }; | ||
applicationManager.startApplication = function (appId, framework) { | ||
isStartApplicationCalled = true; | ||
return Future.fromResult(); | ||
}; | ||
applicationManager.tryStartApplication("appId").wait(); | ||
chai_1.assert.isFalse(isStartApplicationCalled, "startApplication must not be called when app is not installed"); | ||
}); | ||
it("does not call startApplication, when application is installed, but canStartApplication returns false", function () { | ||
var isStartApplicationCalled = false; | ||
applicationManager.canStartApplication = function () { return false; }; | ||
applicationManager.isApplicationInstalled = function (appId) { return Future.fromResult(true); }; | ||
applicationManager.startApplication = function (appId, framework) { | ||
@@ -563,11 +550,2 @@ isStartApplicationCalled = true; | ||
}; | ||
it("when isApplicationInstalled throws error", function () { | ||
applicationManager.canStartApplication = function () { return true; }; | ||
applicationManager.isApplicationInstalled = function (appId) { | ||
return (function () { | ||
throw error; | ||
}).future()(); | ||
}; | ||
assertDoesNotThrow(); | ||
}); | ||
it("when canStartApplication throws error", function () { | ||
@@ -574,0 +552,0 @@ applicationManager.canStartApplication = function () { |
Sorry, the diff of this file is too big to display
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
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
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
9845474
214
20644
1067
12