From c720af5c4814eb8d2397bdf41da930d8370a89bd Mon Sep 17 00:00:00 2001 From: Tsvetan Raikov Date: Thu, 30 Jun 2016 16:16:35 +0300 Subject: [PATCH 1/2] Fixed: Livesync both Android and iOS at the same time, only android updates --- lib/npm-installation-manager.ts | 5 +++++ lib/services/livesync/android-livesync-service.ts | 2 +- lib/tools/broccoli/builder.ts | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/npm-installation-manager.ts b/lib/npm-installation-manager.ts index 8fb2585517..834c06104b 100644 --- a/lib/npm-installation-manager.ts +++ b/lib/npm-installation-manager.ts @@ -106,6 +106,11 @@ export class NpmInstallationManager implements INpmInstallationManager { public install(packageName: string, opts?: INpmInstallOptions): IFuture { return (() => { + + while (this.$lockfile.check().wait()) { + ; + } + this.$lockfile.lock().wait(); try { diff --git a/lib/services/livesync/android-livesync-service.ts b/lib/services/livesync/android-livesync-service.ts index 7e0adff6db..1427e2345c 100644 --- a/lib/services/livesync/android-livesync-service.ts +++ b/lib/services/livesync/android-livesync-service.ts @@ -7,7 +7,7 @@ import * as path from "path"; import * as net from "net"; class AndroidLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase implements IPlatformLiveSyncService { - private static BACKEND_PORT = 18181; + private static BACKEND_PORT = 18182; constructor(_device: Mobile.IDevice, private $fs: IFileSystem, diff --git a/lib/tools/broccoli/builder.ts b/lib/tools/broccoli/builder.ts index 4eca756bce..cf88bc7f86 100644 --- a/lib/tools/broccoli/builder.ts +++ b/lib/tools/broccoli/builder.ts @@ -34,6 +34,11 @@ export class Builder implements IBroccoliBuilder { stat: true }, (er: Error, files: string[]) => { fiberBootstrap.run(() => { + + while (this.$lockfile.check().wait()) { + ; + } + this.$lockfile.lock().wait(); if (er) { if (!future.isResolved()) { From 80d31725ccd6f3ee2a631094538b584ffbfbca85 Mon Sep 17 00:00:00 2001 From: Tsvetan Raikov Date: Fri, 1 Jul 2016 17:21:51 +0300 Subject: [PATCH 2/2] Livesync without platform syncs all devices --- lib/common | 2 +- lib/services/livesync/livesync-service.ts | 54 ++++++++++++++++------- lib/services/platform-service.ts | 2 +- lib/services/test-execution-service.ts | 2 +- test/stubs.ts | 5 +++ 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/lib/common b/lib/common index bd7e3a1874..ff19181bb1 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit bd7e3a1874022d790813538065a9424cd3a2b7f6 +Subproject commit ff19181bb1ed1247cc1120c4ad8895597b737639 diff --git a/lib/services/livesync/livesync-service.ts b/lib/services/livesync/livesync-service.ts index 4984f3fc6d..cceb207adb 100644 --- a/lib/services/livesync/livesync-service.ts +++ b/lib/services/livesync/livesync-service.ts @@ -16,6 +16,8 @@ class LiveSyncService implements ILiveSyncService { private $projectDataService: IProjectDataService, private $prompter: IPrompter, private $injector: IInjector, + private $mobileHelper: Mobile.IMobileHelper, + private $devicesService: Mobile.IDevicesService, private $options: IOptions) { } private ensureAndroidFrameworkVersion(platformData: IPlatformData): IFuture { // TODO: this can be moved inside command or canExecute function @@ -42,32 +44,50 @@ class LiveSyncService implements ILiveSyncService { public liveSync(platform: string): IFuture { return (() => { - platform = this.$liveSyncServiceBase.getPlatform(platform).wait(); - let platformLowerCase = platform.toLowerCase(); - - if (!this.$platformService.preparePlatform(platformLowerCase).wait()) { - this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation."); + let liveSyncData: ILiveSyncData[] = []; + this.$devicesService.initialize({ skipInferPlatform: true }).wait(); + if (platform) { + liveSyncData.push(this.prepareLiveSyncData(platform)); + } else if (this.$options.device) { + platform = this.$devicesService.getDeviceByIdentifier(this.$options.device).deviceInfo.platform; + liveSyncData.push(this.prepareLiveSyncData(platform)); + } else { + for(let installedPlatform of this.$platformService.getInstalledPlatforms().wait()) { + liveSyncData.push(this.prepareLiveSyncData(installedPlatform)); + } } this._isInitialized = true; // If we want before-prepare hooks to work properly, this should be set after preparePlatform function - this.liveSyncCore(platform).wait(); + this.liveSyncCore(liveSyncData).wait(); }).future()(); } + private prepareLiveSyncData(platform: string): ILiveSyncData { + platform = this.$liveSyncServiceBase.getPlatform(platform).wait(); + if (!this.$platformService.preparePlatform(platform.toLowerCase()).wait()) { + this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation."); + } + + let platformData = this.$platformsData.getPlatformData(platform.toLowerCase()); + if (this.$mobileHelper.isAndroidPlatform(platform)) { + this.ensureAndroidFrameworkVersion(platformData).wait(); + } + let liveSyncData: ILiveSyncData = { + platform: platform, + appIdentifier: this.$projectData.projectId, + projectFilesPath: path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME), + syncWorkingDirectory: path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME), + excludedProjectDirsAndFiles: this.$options.release ? constants.LIVESYNC_EXCLUDED_FILE_PATTERNS : [], + forceExecuteFullSync: this.forceExecuteFullSync + }; + + return liveSyncData; + } + @helpers.hook('livesync') - private liveSyncCore(platform: string): IFuture { + private liveSyncCore(liveSyncData: ILiveSyncData[]): IFuture { return (() => { - let platformData = this.$platformsData.getPlatformData(platform.toLowerCase()); - this.ensureAndroidFrameworkVersion(platformData).wait(); - let liveSyncData: ILiveSyncData = { - platform: platform, - appIdentifier: this.$projectData.projectId, - projectFilesPath: path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME), - syncWorkingDirectory: path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME), - excludedProjectDirsAndFiles: this.$options.release ? constants.LIVESYNC_EXCLUDED_FILE_PATTERNS : [], - forceExecuteFullSync: this.forceExecuteFullSync - }; this.$liveSyncServiceBase.sync(liveSyncData).wait(); }).future()(); } diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index ddded3e00a..e5b00c682c 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -322,7 +322,7 @@ export class PlatformService implements IPlatformService { // Replace placeholders in configuration files platformData.platformProjectService.interpolateConfigurationFile().wait(); - this.$logger.out("Project successfully prepared"); + this.$logger.out("Project successfully prepared ("+platform+")"); return true; }).future()(); } diff --git a/lib/services/test-execution-service.ts b/lib/services/test-execution-service.ts index 7f654fb579..366a8b8c78 100644 --- a/lib/services/test-execution-service.ts +++ b/lib/services/test-execution-service.ts @@ -231,7 +231,7 @@ class TestExecutionService implements ITestExecutionService { excludedProjectDirsAndFiles: this.$options.release ? constants.LIVESYNC_EXCLUDED_FILE_PATTERNS : [] }; - this.$liveSyncServiceBase.sync(liveSyncData).wait(); + this.$liveSyncServiceBase.sync([liveSyncData]).wait(); }).future()(); } } diff --git a/test/stubs.ts b/test/stubs.ts index 9dba65a3c3..fa5d3d501b 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -410,6 +410,11 @@ export class HooksServiceStub implements IHooksService { } export class LockFile { + + check(): IFuture { + return (() => { return false; }).future()(); + } + lock(): IFuture { return (() => {}).future()(); }