Skip to content

Commit 4e4197e

Browse files
author
Dimitar Kerezov
committed
Fix Success livesync and run fail messages
1 parent e6c2821 commit 4e4197e

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

lib/commands/run.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ERROR_NO_VALID_SUBCOMMAND_FORMAT } from "../common/constants";
2+
13
export class RunCommandBase implements ICommand {
24
protected platform: string;
35

@@ -7,19 +9,24 @@ export class RunCommandBase implements ICommand {
79
protected $options: IOptions,
810
protected $emulatorPlatformService: IEmulatorPlatformService,
911
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
12+
protected $errors: IErrors,
1013
private $devicesService: Mobile.IDevicesService,
1114
private $hostInfo: IHostInfo,
1215
private $iosDeviceOperations: IIOSDeviceOperations,
1316
private $mobileHelper: Mobile.IMobileHelper) {
14-
this.$projectData.initializeProjectData();
1517
}
1618

17-
public allowedParameters: ICommandParameter[] = [ ];
19+
public allowedParameters: ICommandParameter[] = [];
1820
public async execute(args: string[]): Promise<void> {
1921
return this.executeCore(args);
2022
}
2123

2224
public async canExecute(args: string[]): Promise<boolean> {
25+
if (args.length) {
26+
this.$errors.fail(ERROR_NO_VALID_SUBCOMMAND_FORMAT, "run");
27+
}
28+
29+
this.$projectData.initializeProjectData();
2330
if (!this.platform && !this.$hostInfo.isDarwin) {
2431
this.platform = this.$devicePlatformsConstants.Android;
2532
}
@@ -43,7 +50,7 @@ export class RunCommandBase implements ICommand {
4350
identifier: d.deviceInfo.identifier,
4451
buildAction: async (): Promise<string> => {
4552
const buildConfig: IBuildConfig = {
46-
buildForDevice: !d.isEmulator, // this.$options.forDevice,
53+
buildForDevice: !d.isEmulator,
4754
projectDir: this.$options.path,
4855
clean: this.$options.clean,
4956
teamId: this.$options.teamId,
@@ -65,25 +72,26 @@ export class RunCommandBase implements ICommand {
6572
return info;
6673
});
6774

68-
// if (this.$options.release) {
69-
// const deployOpts: IRunPlatformOptions = {
70-
// device: this.$options.device,
71-
// emulator: this.$options.emulator,
72-
// justlaunch: this.$options.justlaunch,
73-
// };
74-
75-
// await this.$platformService.startApplication(args[0], deployOpts, this.$projectData.projectId);
76-
// return this.$platformService.trackProjectType(this.$projectData);
77-
// }
78-
7975
if ((!this.platform || this.$mobileHelper.isiOSPlatform(this.platform)) && (this.$options.watch || !this.$options.justlaunch)) {
8076
this.$iosDeviceOperations.setShouldDispose(false);
8177
}
8278

79+
if (this.$options.release) {
80+
const deployOpts: IRunPlatformOptions = {
81+
device: this.$options.device,
82+
emulator: this.$options.emulator,
83+
justlaunch: this.$options.justlaunch,
84+
};
85+
86+
await this.$platformService.startApplication(args[0], deployOpts, this.$projectData.projectId);
87+
return this.$platformService.trackProjectType(this.$projectData);
88+
}
89+
8390
const liveSyncInfo: ILiveSyncInfo = { projectDir: this.$projectData.projectDir, skipWatcher: !this.$options.watch, watchAllFiles: this.$options.syncAllFiles };
8491
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
8592
}
8693
}
94+
8795
$injector.registerCommand("run|*all", RunCommandBase);
8896

8997
export class RunIosCommand extends RunCommandBase implements ICommand {
@@ -95,7 +103,7 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
95103
constructor($platformService: IPlatformService,
96104
private $platformsData: IPlatformsData,
97105
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
98-
private $errors: IErrors,
106+
protected $errors: IErrors,
99107
$liveSyncService: ILiveSyncService,
100108
$projectData: IProjectData,
101109
$options: IOptions,
@@ -104,7 +112,7 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
104112
$hostInfo: IHostInfo,
105113
$iosDeviceOperations: IIOSDeviceOperations,
106114
$mobileHelper: Mobile.IMobileHelper) {
107-
super($platformService, $liveSyncService, $projectData, $options, $emulatorPlatformService, $devicePlatformsConstants, $devicesService, $hostInfo, $iosDeviceOperations, $mobileHelper);
115+
super($platformService, $liveSyncService, $projectData, $options, $emulatorPlatformService, $devicePlatformsConstants, $errors, $devicesService, $hostInfo, $iosDeviceOperations, $mobileHelper);
108116
}
109117

110118
public async execute(args: string[]): Promise<void> {
@@ -131,7 +139,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
131139
constructor($platformService: IPlatformService,
132140
private $platformsData: IPlatformsData,
133141
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
134-
private $errors: IErrors,
142+
protected $errors: IErrors,
135143
$liveSyncService: ILiveSyncService,
136144
$projectData: IProjectData,
137145
$options: IOptions,
@@ -140,7 +148,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
140148
$hostInfo: IHostInfo,
141149
$iosDeviceOperations: IIOSDeviceOperations,
142150
$mobileHelper: Mobile.IMobileHelper) {
143-
super($platformService, $liveSyncService, $projectData, $options, $emulatorPlatformService, $devicePlatformsConstants, $devicesService, $hostInfo, $iosDeviceOperations, $mobileHelper);
151+
super($platformService, $liveSyncService, $projectData, $options, $emulatorPlatformService, $devicePlatformsConstants, $errors, $devicesService, $hostInfo, $iosDeviceOperations, $mobileHelper);
144152
}
145153

146154
public async execute(args: string[]): Promise<void> {

lib/common

lib/services/livesync/livesync-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
103103
protected async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo): Promise<void> {
104104
const platformLiveSyncService = this.getLiveSyncService(liveSyncResultInfo.deviceAppData.platform);
105105
try {
106-
// TODO: Assure we are able to self-restart iOS apps on Windows.
107106
await platformLiveSyncService.refreshApplication(projectData, liveSyncResultInfo);
108107
} catch (err) {
109108
this.$logger.info(`Error while trying to start application ${projectData.projectId} on device ${liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier}. Error is: ${err.message || err}`);
@@ -123,6 +122,8 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
123122
syncedFiles: liveSyncResultInfo.modifiedFilesData.map(m => m.getLocalPath()),
124123
deviceIdentifier: liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier
125124
});
125+
126+
this.$logger.info(`Successfully synced application ${liveSyncResultInfo.deviceAppData.appIdentifier} on device ${liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier}.`);
126127
}
127128

128129
private setLiveSyncProcessInfo(projectDir: string, deviceDescriptors: ILiveSyncDeviceInfo[]): void {

0 commit comments

Comments
 (0)