Skip to content

Commit 60cf564

Browse files
author
Nadezhda Atanasova
authored
Update TS to latest release (#2928)
* Update TS to latest release Fix correcponding tests * Update TS to 2.4 *Update dependencies *Fix errors due to new TS rules *Change debug on device logic - there wil be no multiple devicxes debug supported. *Update lib reference
1 parent 895e0bf commit 60cf564

28 files changed

+87
-112
lines changed

lib/commands/debug.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
await this.$platformService.trackProjectType(this.$projectData);
2525

2626
if (this.$options.start) {
27-
return this.$debugLiveSyncService.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
27+
return this.$debugLiveSyncService.printDebugInformation(await this.debugService.debug(debugData, debugOptions));
2828
}
2929

3030
this.$config.debugLivesync = true;
3131

3232
await this.$devicesService.detectCurrentlyAttachedDevices();
3333

34-
const devices = this.$devicesService.getDeviceInstances();
3534
// Now let's take data for each device:
35+
const devices = this.$devicesService.getDeviceInstances();
3636
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices.filter(d => !this.platform || d.deviceInfo.platform === this.platform)
3737
.map(d => {
3838
const info: ILiveSyncDeviceInfo = {
@@ -91,10 +91,7 @@
9191
}
9292

9393
if (this.$devicesService.deviceCount > 1) {
94-
// Starting debugger on emulator.
95-
this.$options.emulator = true;
96-
97-
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);
94+
this.$errors.failWithoutHelp("Multiple devices found! To debug on specific device please select device with --device option.");
9895
}
9996

10097
return true;

lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class LiveSyncPaths {
7979
static FULLSYNC_DIR_NAME = "fullsync";
8080
static IOS_DEVICE_PROJECT_ROOT_PATH = "Library/Application Support/LiveSync";
8181
static IOS_DEVICE_SYNC_ZIP_PATH = "Library/Application Support/LiveSync/sync.zip";
82-
};
82+
}
8383
export const ANGULAR_NAME = "angular";
8484
export const TYPESCRIPT_NAME = "typescript";
8585
export const BUILD_OUTPUT_EVENT_NAME = "buildOutput";

lib/definitions/debug.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ interface IDebugServiceBase extends NodeJS.EventEmitter {
9696
* @param {IDebugOptions} debugOptions Describe possible options to modify the behaivor of the debug operation, for example stop on the first line.
9797
* @returns {Promise<T>} Array of URLs that can be used for debugging or a string representing a single url that can be used for debugging.
9898
*/
99-
debug<T>(debugData: IDebugData, debugOptions: IDebugOptions): Promise<T>;
99+
debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string>;
100100
}
101101

102102
interface IDebugService {

lib/definitions/livesync.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ interface IDebugLiveSyncService extends ILiveSyncService {
174174
* @param {string[]} information Array of information to be printed. Note that false-like values will be stripped from the array.
175175
* @returns {void}
176176
*/
177-
printDebugInformation(information: string[]): void;
177+
printDebugInformation(information: string): void;
178178
}
179179

180180
interface ILiveSyncWatchInfo {

lib/services/android-debug-service.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
1818
this._device = newDevice;
1919
}
2020

21-
constructor(private $devicesService: Mobile.IDevicesService,
21+
constructor(protected $devicesService: Mobile.IDevicesService,
2222
private $errors: IErrors,
2323
private $logger: ILogger,
2424
private $config: IConfiguration,
2525
private $androidDeviceDiscovery: Mobile.IDeviceDiscovery,
2626
private $androidProcessService: Mobile.IAndroidProcessService,
2727
private $net: INet) {
28-
super();
28+
super($devicesService);
2929
}
3030

31-
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
31+
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
3232
return debugOptions.emulator
3333
? this.debugOnEmulator(debugData, debugOptions)
3434
: this.debugOnDevice(debugData, debugOptions);
@@ -49,7 +49,7 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
4949
return;
5050
}
5151

52-
private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
52+
private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
5353
// Assure we've detected the emulator as device
5454
// For example in case deployOnEmulator had stated new emulator instance
5555
// we need some time to detect it. Let's force detection.
@@ -82,7 +82,7 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
8282
return this.device.adb.executeCommand(["forward", `tcp:${local}`, `localabstract:${remote}`]);
8383
}
8484

85-
private async debugOnDevice(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
85+
private async debugOnDevice(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
8686
let packageFile = "";
8787

8888
if (!debugOptions.start && !debugOptions.emulator) {
@@ -94,9 +94,8 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
9494

9595
let action = (device: Mobile.IAndroidDevice): Promise<string> => this.debugCore(device, packageFile, debugData.applicationIdentifier, debugOptions);
9696

97-
const result = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
98-
99-
return _.map(result, r => r.result);
97+
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
98+
return deviceActionResult[0].result;
10099
}
101100

102101
private async debugCore(device: Mobile.IAndroidDevice, packageFile: string, packageName: string, debugOptions: IDebugOptions): Promise<string> {

lib/services/android-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
171171
this.$errors.failWithoutHelp(`Your project have installed ${dependency.name} version ${cleanedVerson} but Android platform requires version ${dependency.version}.`);
172172
}
173173
}
174-
};
174+
}
175175
}
176176

177177
private cleanResValues(targetSdkVersion: number, projectData: IProjectData, frameworkVersion: string): void {

lib/services/debug-service-base.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { EventEmitter } from "events";
22

33
export abstract class DebugServiceBase extends EventEmitter implements IPlatformDebugService {
4+
constructor(protected $devicesService: Mobile.IDevicesService) { super(); }
5+
46
public abstract get platform(): string;
57

6-
public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]>;
8+
public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string>;
79

810
public abstract async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void>;
911

@@ -12,7 +14,8 @@ export abstract class DebugServiceBase extends EventEmitter implements IPlatform
1214
protected getCanExecuteAction(deviceIdentifier: string): (device: Mobile.IDevice) => boolean {
1315
return (device: Mobile.IDevice): boolean => {
1416
if (deviceIdentifier) {
15-
return device.deviceInfo.identifier === deviceIdentifier;
17+
return device.deviceInfo.identifier === deviceIdentifier
18+
|| device.deviceInfo.identifier === this.$devicesService.getDeviceByDeviceOption().deviceInfo.identifier;
1619
} else {
1720
return true;
1821
}

lib/services/debug-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class DebugService extends EventEmitter implements IDebugService {
3636
// For now we can only check if app is running on Android.
3737
// After we find a way to check on iOS we should use it here.
3838
const isAppRunning = true;
39-
let result: string[];
39+
let result: string;
4040
debugOptions.chrome = true;
4141

4242
const debugService = this.getDebugService(device);
@@ -59,9 +59,9 @@ export class DebugService extends EventEmitter implements IDebugService {
5959
this.$errors.failWithoutHelp(`Debugging on iOS devices is not supported for ${platform()} yet.`);
6060
}
6161

62-
result = await debugService.debug<string[]>(debugData, debugOptions);
62+
result = await debugService.debug(debugData, debugOptions);
6363
} else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
64-
result = await debugService.debug<string[]>(debugData, debugOptions);
64+
result = await debugService.debug(debugData, debugOptions);
6565
}
6666

6767
return _.first(result);

lib/services/init-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class InitService implements IInitService {
5656

5757
projectData[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE][platformData.frameworkPackageName] = _.extend(currentPlatformData, await this.getVersionData(platformData.frameworkPackageName));
5858
}
59-
};
59+
}
6060
}
6161

6262
let dependencies = projectData.dependencies;

0 commit comments

Comments
 (0)