Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/npm-installation-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export class NpmInstallationManager implements INpmInstallationManager {

public install(packageName: string, opts?: INpmInstallOptions): IFuture<string> {
return (() => {

while (this.$lockfile.check().wait()) {
;
}

this.$lockfile.lock().wait();

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/livesync/android-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as path from "path";
import * as net from "net";

class AndroidLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<Mobile.IAndroidDevice> implements IPlatformLiveSyncService {
private static BACKEND_PORT = 18181;
private static BACKEND_PORT = 18182;

constructor(_device: Mobile.IDevice,
private $fs: IFileSystem,
Expand Down
54 changes: 37 additions & 17 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> { // TODO: this can be moved inside command or canExecute function
Expand All @@ -42,32 +44,50 @@ class LiveSyncService implements ILiveSyncService {

public liveSync(platform: string): IFuture<void> {
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<void>()();
}

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<void> {
private liveSyncCore(liveSyncData: ILiveSyncData[]): IFuture<void> {
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<void>()();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>()();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/services/test-execution-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>()();
}
}
Expand Down
5 changes: 5 additions & 0 deletions lib/tools/broccoli/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
5 changes: 5 additions & 0 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ export class HooksServiceStub implements IHooksService {
}

export class LockFile {

check(): IFuture<boolean> {
return (() => { return false; }).future<boolean>()();
}

lock(): IFuture<void> {
return (() => {}).future<void>()();
}
Expand Down