From 1407af70d53da53230c049cee730fb454b1c0e51 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Fri, 13 Nov 2015 17:55:13 +0200 Subject: [PATCH 1/9] Remove .ts from tns-core-modules package when moving it to platforms dir The new tns-core-modules package has .d.ts files. We should skip them when moving tns-core-modules to platforms dir. The current logic is - copy everything from node_modules to tns_modules dir. After that move everything from tns_modules/tns-core-modules dir to tns_modules and delete tns-core-modules. Add logic to delete .ts file BEFORE moving the files from tns_modules/tns-core-modules dir to tns_modules. --- lib/tools/broccoli/node-modules-dest-copy.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/tools/broccoli/node-modules-dest-copy.ts b/lib/tools/broccoli/node-modules-dest-copy.ts index 302e306498..d30e845cba 100644 --- a/lib/tools/broccoli/node-modules-dest-copy.ts +++ b/lib/tools/broccoli/node-modules-dest-copy.ts @@ -7,6 +7,8 @@ import * as semver from "semver"; import * as shelljs from "shelljs"; import {wrapBroccoliPlugin} from './broccoli-plugin-wrapper-factory'; import * as constants from "../../constants"; +import * as minimatch from "minimatch"; +import Future = require("fibers/future"); /** * Intercepts each directory as it is copied to the destination tempdir, @@ -79,6 +81,12 @@ export class DestCopy implements IBroccoliPlugin { if (dependency.name === constants.TNS_CORE_MODULES_NAME) { let tnsCoreModulesResourcePath = path.join(this.outputRoot, constants.TNS_CORE_MODULES_NAME); + + // Remove .ts files + let allFiles = this.$fs.enumerateFilesInDirectorySync(tnsCoreModulesResourcePath); + let deleteFilesFutures = allFiles.filter(file => minimatch(file, "**/*.ts", {nocase: true})).map(file => this.$fs.deleteFile(file)); + Future.wait(deleteFilesFutures); + shelljs.cp("-Rf", path.join(tnsCoreModulesResourcePath, "*"), this.outputRoot); this.$fs.deleteDirectory(tnsCoreModulesResourcePath).wait(); } From 890cc8cdd7218abd6eb21483645f9fc6df203917 Mon Sep 17 00:00:00 2001 From: Fatme Havaluova Date: Mon, 16 Nov 2015 11:03:16 +0200 Subject: [PATCH 2/9] Fix doctor command Check if pod version is a valid semver version --- lib/services/doctor-service.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index a79d208efd..f016d51834 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -45,15 +45,22 @@ class DoctorService implements IDoctorService { result = true; } - if(!sysInfo.cocoapodVer ) { + if(!sysInfo.cocoapodVer) { this.$logger.warn("WARNING: CocoaPod is not installed or is not configured properly."); this.$logger.out("You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL + "To be able to build such projects, verify that you have installed CocoaPod."); result = true; } - if(sysInfo.cocoapodVer && semver.lt(sysInfo.cocoapodVer, DoctorService.MIN_SUPPORTED_POD_VERSION)) { - this.$logger.warn(`WARNING: CocoaPods version is lower than ${DoctorService.MIN_SUPPORTED_POD_VERSION}`); + if (sysInfo.cocoapodVer && semver.valid(sysInfo.cocoapodVer) === null) { + this.$logger.warn(`WARNING: CocoaPods version is not a valid semver version.`); + this.$logger.out("You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL + + `To be able to build such projects, verify that you have at least ${DoctorService.MIN_SUPPORTED_POD_VERSION} version installed.`); + result = true; + } + + if (sysInfo.cocoapodVer && semver.valid(sysInfo.cocoapodVer) && semver.lt(sysInfo.cocoapodVer, DoctorService.MIN_SUPPORTED_POD_VERSION)) { + this.$logger.warn(`WARNING: CocoaPods version is lower than ${DoctorService.MIN_SUPPORTED_POD_VERSION}.`); this.$logger.out("You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL + `To be able to build such projects, verify that you have at least ${DoctorService.MIN_SUPPORTED_POD_VERSION} version installed.`); result = true; From 358da57394524e120f680a8b644a3d1211e74b56 Mon Sep 17 00:00:00 2001 From: Fatme Havaluova Date: Fri, 13 Nov 2015 18:30:36 +0200 Subject: [PATCH 3/9] Respect deleted files by livesync command --- lib/common | 2 +- lib/services/usb-livesync-service.ts | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/common b/lib/common index 7ee22324d2..ee56ac69e0 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 7ee22324d20cc83ea44f58f85d0118c8b9f511b2 +Subproject commit ee56ac69e000745ecf1cd978e4ade4792d92f66a diff --git a/lib/services/usb-livesync-service.ts b/lib/services/usb-livesync-service.ts index 321eab9f0f..a478bb462b 100644 --- a/lib/services/usb-livesync-service.ts +++ b/lib/services/usb-livesync-service.ts @@ -217,6 +217,14 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService { return this.$iOSEmulatorServices.postDarwinNotification(this.$iOSNotification.attachRequest); } + public removeFile(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture { + return (() => { + _.each(localToDevicePaths, localToDevicePathData => { + this.device.fileSystem.deleteFile(localToDevicePathData.getDevicePath(), appIdentifier); + }); + }).future()(); + } + private sendPageReloadMessage(socket: net.Socket): void { try { this.sendPageReloadMessageCore(socket); @@ -265,7 +273,7 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android public beforeLiveSyncAction(deviceAppData: Mobile.IDeviceAppData): IFuture { return (() => { - let deviceRootPath = `/data/local/tmp/${deviceAppData.appIdentifier}`; + let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier); this.device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"), this.$mobileHelper.buildDevicePath(deviceRootPath, "sync"), this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync")]).wait(); @@ -279,6 +287,21 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android }).future()(); } + public removeFile(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture { + return (() => { + let deviceRootPath = this.getDeviceRootPath(appIdentifier); + _.each(localToDevicePaths, localToDevicePathData => { + let relativeUnixPath = _.trimLeft(helpers.fromWindowsRelativePathToUnix(localToDevicePathData.getRelativeToProjectBasePath()), "/"); + let deviceFilePath = this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync", relativeUnixPath); + this.device.adb.executeShellCommand(["mkdir", "-p", path.dirname(deviceFilePath), "&&", "touch", deviceFilePath]).wait(); + }); + }).future()(); + } + + private getDeviceRootPath(appIdentifier: string): string { + return `/data/local/tmp/${appIdentifier}`; + } + private sendPageReloadMessage(): IFuture { let future = new Future(); From cae6c99b20e808615f937d7f3f4f44fb1f071959 Mon Sep 17 00:00:00 2001 From: Todor Totev Date: Mon, 16 Nov 2015 15:55:12 +0200 Subject: [PATCH 4/9] Check for devices before building the project See https://github.com/NativeScript/nativescript-cli/issues/1167 --- lib/services/init-service.ts | 1 - lib/services/platform-service.ts | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/services/init-service.ts b/lib/services/init-service.ts index 244053198e..fdf0cb73b3 100644 --- a/lib/services/init-service.ts +++ b/lib/services/init-service.ts @@ -16,7 +16,6 @@ export class InitService implements IInitService { private _projectFilePath: string; constructor(private $fs: IFileSystem, - private $errors: IErrors, private $logger: ILogger, private $options: IOptions, private $injector: IInjector, diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 948c169c1c..3afe67c7f3 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -335,6 +335,11 @@ export class PlatformService implements IPlatformService { this.ensurePlatformInstalled(platform).wait(); let platformData = this.$platformsData.getPlatformData(platform); + this.$devicesService.initialize({platform: platform, deviceId: this.$options.device}).wait(); + if (this.$devicesService.deviceCount < 1) { + this.$errors.failWithoutHelp("Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again."); + } + let cachedDeviceOption = this.$options.forDevice; this.$options.forDevice = true; this.buildPlatform(platform, buildConfig).wait(); @@ -344,7 +349,6 @@ export class PlatformService implements IPlatformService { let packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName; this.$logger.out("Using ", packageFile); - this.$devicesService.initialize({platform: platform, deviceId: this.$options.device}).wait(); let action = (device: Mobile.IDevice): IFuture => { return (() => { platformData.platformProjectService.deploy(device.deviceInfo.identifier).wait(); From 7b3c8434b6fe2e9cb818b4930b7fd9ad75e6c03d Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 16 Nov 2015 21:59:46 +0200 Subject: [PATCH 5/9] Use emulator executable from ANDROID_HOME In case ANDROID_HOME is defined, use the emulator executable based on it, not from PATH environment variable. --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index ee56ac69e0..fbebba6364 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit ee56ac69e000745ecf1cd978e4ade4792d92f66a +Subproject commit fbebba63640f0dd8600d6f599e7f4076bfd27cea From 9f4667a0e2b359a3f9f24302a7848cde430e7b8f Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 16 Nov 2015 23:36:32 +0200 Subject: [PATCH 6/9] Fix getting of cocoapod version `pod --version` command, which is used to determine the version of cocoapods, might return some warnings. Here's a sample output: ``` WARNING: CocoaPods requires your terminal to be using UTF-8 encoding. Consider adding the following to ~/.profile: export LANG=en_US.UTF-8 0.39.0 ``` Make sure to get the real version in this output (0.39.0). --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index fbebba6364..f380a5d163 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit fbebba63640f0dd8600d6f599e7f4076bfd27cea +Subproject commit f380a5d163842eb309395797d5c169182388307f From 6a12b0f1d856f87a7b3e44543ec7de20a5c4df1c Mon Sep 17 00:00:00 2001 From: Fatme Havaluova Date: Mon, 16 Nov 2015 11:28:06 +0200 Subject: [PATCH 7/9] Release the console after livesync command and fix a typo. The console is not release if `tns livesync ios` command is executed --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index f380a5d163..ad92d5cca7 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit f380a5d163842eb309395797d5c169182388307f +Subproject commit ad92d5cca781e756b8cea6c8dfd8f38d0aee6f7c From 74da44ff379b6b9c4ffcc398c209957732ef2ea3 Mon Sep 17 00:00:00 2001 From: Fatme Havaluova Date: Tue, 17 Nov 2015 13:24:49 +0200 Subject: [PATCH 8/9] Use npm api to install all project dependencies --- lib/services/plugins-service.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts index 0951f4de4e..781b455d22 100644 --- a/lib/services/plugins-service.ts +++ b/lib/services/plugins-service.ts @@ -162,11 +162,7 @@ export class PluginsService implements IPluginsService { let packageJsonContent = this.$fs.readJson(this.getPackageJsonFilePath()).wait(); let allDependencies = _.keys(packageJsonContent.dependencies).concat(_.keys(packageJsonContent.devDependencies)); if(this.$options.force || _.difference(allDependencies, installedDependencies).length) { - let command = "npm install "; - if(this.$options.ignoreScripts) { - command += "--ignore-scripts"; - } - this.$childProcess.exec(command, { cwd: this.$projectData.projectDir }).wait(); + this.$npm.install(this.$projectData.projectDir, this.$projectData.projectDir, { "ignore-scripts": this.$options.ignoreScripts }).wait(); } }).future()(); } From 5e856723c928ba04c780a5bd049512d82495ea5c Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 18 Nov 2015 09:05:59 +0200 Subject: [PATCH 9/9] Require `messages` in bootstrap Bootstrap does not know where to find "messages" as we have missed the require. Tell him where the messages class is located. --- lib/bootstrap.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bootstrap.ts b/lib/bootstrap.ts index edf24f1af4..670aeabb40 100644 --- a/lib/bootstrap.ts +++ b/lib/bootstrap.ts @@ -90,3 +90,4 @@ $injector.require("iOSNotificationService", "./services/ios-notification-service $injector.require("socketProxyFactory", "./device-sockets/ios/socket-proxy-factory"); $injector.require("iOSNotification", "./device-sockets/ios/notification"); $injector.require("iOSSocketRequestExecutor", "./device-sockets/ios/socket-request-executor"); +$injector.require("messages", "./messages");