-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdebug-livesync-service.ts
79 lines (65 loc) · 2.87 KB
/
debug-livesync-service.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
import { EOL } from "os";
import { LiveSyncService } from "./livesync-service";
export class DebugLiveSyncService extends LiveSyncService implements IDebugLiveSyncService {
constructor(protected $platformService: IPlatformService,
$projectDataService: IProjectDataService,
protected $devicesService: Mobile.IDevicesService,
$mobileHelper: Mobile.IMobileHelper,
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder,
protected $logger: ILogger,
$processService: IProcessService,
$hooksService: IHooksService,
$pluginsService: IPluginsService,
protected $injector: IInjector,
private $options: IOptions,
private $debugDataService: IDebugDataService,
private $projectData: IProjectData,
private $debugService: IDebugService,
private $config: IConfiguration) {
super($platformService,
$projectDataService,
$devicesService,
$mobileHelper,
$devicePlatformsConstants,
$nodeModulesDependenciesBuilder,
$logger,
$processService,
$hooksService,
$pluginsService,
$injector);
}
protected async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo): Promise<void> {
const debugOptions = this.$options;
const deployOptions: IDeployPlatformOptions = {
clean: this.$options.clean,
device: this.$options.device,
emulator: this.$options.emulator,
platformTemplate: this.$options.platformTemplate,
projectDir: this.$options.path,
release: this.$options.release,
provision: this.$options.provision,
teamId: this.$options.teamId
};
let debugData = this.$debugDataService.createDebugData(this.$projectData, { device: liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier });
const debugService = this.$debugService.getDebugService(liveSyncResultInfo.deviceAppData.device);
await this.$platformService.trackProjectType(this.$projectData);
if (this.$options.start) {
return this.printDebugInformation(await debugService.debug(debugData, debugOptions));
}
const deviceAppData = liveSyncResultInfo.deviceAppData;
this.$config.debugLivesync = true;
await debugService.debugStop();
let applicationId = deviceAppData.appIdentifier;
await deviceAppData.device.applicationManager.stopApplication(applicationId, projectData.projectName);
const buildConfig: IBuildConfig = _.merge({ buildForDevice: !deviceAppData.device.isEmulator }, deployOptions);
debugData.pathToAppPackage = this.$platformService.lastOutputPath(debugService.platform, buildConfig, projectData);
this.printDebugInformation(await debugService.debug(debugData, debugOptions));
}
public printDebugInformation(information: string): void {
if (!!information) {
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${information}${EOL}`.cyan);
}
}
}
$injector.register("debugLiveSyncService", DebugLiveSyncService);