-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdebug.ts
93 lines (78 loc) · 3.5 KB
/
debug.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
export class DebugPlatformCommand implements ICommand {
constructor(private debugService: IDebugService,
private $devicesService: Mobile.IDevicesService,
private $injector: IInjector,
private $logger: ILogger,
private $childProcess: IChildProcess,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $config: IConfiguration,
private $usbLiveSyncService: ILiveSyncService,
protected $options: IOptions) { }
execute(args: string[]): IFuture<void> {
if (this.$options.watch) {
this.$options.rebuild = false;
}
if (!this.$options.rebuild && !this.$options.start) {
this.$config.debugLivesync = true;
let applicationReloadAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> => {
return (() => {
let projectData: IProjectData = this.$injector.resolve("projectData");
this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${deviceAppData.device.deviceInfo.identifier}.`);
this.debugService.debugStop().wait();
let applicationId = deviceAppData.appIdentifier;
if (deviceAppData.device.isEmulator && deviceAppData.platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
applicationId = projectData.projectName;
}
deviceAppData.device.applicationManager.stopApplication(applicationId).wait();
this.debugService.debug().wait();
}).future<void>()();
};
return this.$usbLiveSyncService.liveSync(this.$devicesService.platform, applicationReloadAction);
}
return this.debugService.debug();
}
allowedParameters: ICommandParameter[] = [];
canExecute(args: string[]): IFuture<boolean> {
return ((): boolean => {
this.$devicesService.initialize({ platform: this.debugService.platform, deviceId: this.$options.device }).wait();
// Start emulator if --emulator is selected or no devices found.
if(this.$options.emulator || this.$devicesService.deviceCount === 0) {
return true;
}
if (this.$devicesService.deviceCount > 1) {
// Starting debugger on emulator.
this.$options.emulator = true;
this.$logger.warn("Multiple devices found! Starting debugger on emulator. If you want to debug on specific device please select device with --device option.".yellow.bold);
}
return true;
}).future<boolean>()();
}
}
export class DebugIOSCommand extends DebugPlatformCommand {
constructor($iOSDebugService: IDebugService,
$devicesService: Mobile.IDevicesService,
$injector: IInjector,
$logger: ILogger,
$childProcess: IChildProcess,
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$config: IConfiguration,
$usbLiveSyncService: ILiveSyncService,
$options: IOptions) {
super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $options);
}
}
$injector.registerCommand("debug|ios", DebugIOSCommand);
export class DebugAndroidCommand extends DebugPlatformCommand {
constructor($androidDebugService: IDebugService,
$devicesService: Mobile.IDevicesService,
$injector: IInjector,
$logger: ILogger,
$childProcess: IChildProcess,
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$config: IConfiguration,
$usbLiveSyncService: ILiveSyncService,
$options: IOptions) {
super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $options);
}
}
$injector.registerCommand("debug|android", DebugAndroidCommand);