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

+3-6
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

+1-1
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

+1-1
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

+1-1
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

+7-8
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

+1-1
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

+5-2
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

+3-3
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

+1-1
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;

lib/services/ios-debug-service.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
2121
private _childProcess: ChildProcess;
2222
private _socketProxy: any;
2323

24-
constructor(private $platformService: IPlatformService,
24+
constructor(protected $devicesService: Mobile.IDevicesService,
25+
private $platformService: IPlatformService,
2526
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices,
26-
private $devicesService: Mobile.IDevicesService,
2727
private $childProcess: IChildProcess,
2828
private $logger: ILogger,
2929
private $errors: IErrors,
@@ -32,7 +32,7 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
3232
private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
3333
private $processService: IProcessService,
3434
private $socketProxyFactory: ISocketProxyFactory) {
35-
super();
35+
super($devicesService);
3636
this.$processService.attachToProcessExitSignals(this, this.debugStop);
3737
this.$socketProxyFactory.on(CONNECTION_ERROR_EVENT_NAME, (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e));
3838
}
@@ -41,7 +41,7 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
4141
return "ios";
4242
}
4343

44-
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
44+
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
4545
if (debugOptions.debugBrk && debugOptions.start) {
4646
this.$errors.failWithoutHelp("Expected exactly one of the --debug-brk or --start options.");
4747
}
@@ -52,9 +52,9 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
5252

5353
if (debugOptions.emulator) {
5454
if (debugOptions.start) {
55-
return [await this.emulatorStart(debugData, debugOptions)];
55+
return await this.emulatorStart(debugData, debugOptions);
5656
} else {
57-
return [await this.emulatorDebugBrk(debugData, debugOptions)];
57+
return await this.emulatorDebugBrk(debugData, debugOptions);
5858
}
5959
} else {
6060
if (debugOptions.start) {
@@ -149,7 +149,7 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
149149
return result;
150150
}
151151

152-
private async deviceDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
152+
private async deviceDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
153153
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
154154
const action = async (device: iOSDevice.IOSDevice) => {
155155
if (device.isEmulator) {
@@ -171,20 +171,20 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
171171
return result;
172172
};
173173

174-
const results = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
175-
return _.map(results, r => r.result);
174+
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
175+
return deviceActionResult[0].result;
176176
}
177177

178178
private async debugBrkCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
179179
await this.$iOSSocketRequestExecutor.executeLaunchRequest(device.deviceInfo.identifier, TIMEOUT_SECONDS, TIMEOUT_SECONDS, debugData.applicationIdentifier, debugOptions.debugBrk);
180180
return this.wireDebuggerClient(debugData, debugOptions, device);
181181
}
182182

183-
private async deviceStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
183+
private async deviceStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
184184
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
185185
const action = async (device: Mobile.IiOSDevice) => device.isEmulator ? await this.emulatorStart(debugData, debugOptions) : await this.deviceStartCore(device, debugData, debugOptions);
186-
const results = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
187-
return _.map(results, r => r.result);
186+
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
187+
return deviceActionResult[0].result;
188188
}
189189

190190
private async deviceStartCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {

lib/services/ios-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
933933
private getAllLibsForPluginWithFileExtension(pluginData: IPluginData, fileExtension: string): string[] {
934934
let filterCallback = (fileName: string, pluginPlatformsFolderPath: string) => path.extname(fileName) === fileExtension;
935935
return this.getAllNativeLibrariesForPlugin(pluginData, IOSProjectService.IOS_PLATFORM_NAME, filterCallback);
936-
};
936+
}
937937

938938
private buildPathToCurrentXcodeProjectFile(projectData: IProjectData): string {
939939
return path.join(projectData.platformsDir, "ios", `${projectData.projectName}.xcodeproj`, "project.pbxproj");

lib/services/livesync/debug-livesync-service.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class DebugLiveSyncService extends LiveSyncService implements IDebugLiveS
5252
await this.$platformService.trackProjectType(this.$projectData);
5353

5454
if (this.$options.start) {
55-
return this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
55+
return this.printDebugInformation(await debugService.debug(debugData, debugOptions));
5656
}
5757

5858
const deviceAppData = liveSyncResultInfo.deviceAppData;
@@ -66,14 +66,13 @@ export class DebugLiveSyncService extends LiveSyncService implements IDebugLiveS
6666
const buildConfig: IBuildConfig = _.merge({ buildForDevice: !deviceAppData.device.isEmulator }, deployOptions);
6767
debugData.pathToAppPackage = this.$platformService.lastOutputPath(debugService.platform, buildConfig, projectData);
6868

69-
this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
69+
this.printDebugInformation(await debugService.debug(debugData, debugOptions));
7070
}
7171

72-
public printDebugInformation(information: string[]): void {
73-
information = information.filter(i => !!i);
74-
_.each(information, i => {
75-
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${i}${EOL}`.cyan);
76-
});
72+
public printDebugInformation(information: string): void {
73+
if (!!information) {
74+
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${information}${EOL}`.cyan);
75+
}
7776
}
7877
}
7978

lib/services/platform-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
7373
let version: string;
7474
if (currentPlatformData && currentPlatformData[constants.VERSION_STRING]) {
7575
version = currentPlatformData[constants.VERSION_STRING];
76-
};
76+
}
7777

7878
return version;
7979
}
@@ -669,7 +669,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
669669
} else {
670670
await this.addPlatform(platformParam, platformTemplate, projectData, config);
671671
}
672-
};
672+
}
673673
}
674674

675675
private getCanExecuteAction(platform: string, options: IDeviceEmulator): any {

lib/services/plugins-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class PluginsService implements IPluginsService {
280280
let pluginDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, "tns_modules");
281281
await action(pluginDestinationPath, platform.toLowerCase(), platformData);
282282
}
283-
};
283+
}
284284
}
285285

286286
private getInstalledFrameworkVersion(platform: string, projectData: IProjectData): string {

lib/services/xcconfig-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export class XCConfigService {
44

55
/**
66
* Returns the Value of a Property from a XC Config file.
7-
* @param xcconfigFilePath
7+
* @param xcconfigFilePath
88
* @param propertyName
99
*/
1010
public readPropertyValue(xcconfigFilePath: string, propertyName: string): string {

package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,29 @@
8181
},
8282
"analyze": true,
8383
"devDependencies": {
84-
"@types/chai": "3.4.34",
85-
"@types/chai-as-promised": "0.0.29",
84+
"@types/chai": "4.0.1",
85+
"@types/chai-as-promised": "0.0.31",
8686
"@types/chokidar": "1.6.0",
87-
"@types/lodash": "4.14.50",
8887
"@types/node": "6.0.61",
8988
"@types/qr-image": "3.2.0",
90-
"@types/request": "0.0.42",
89+
"@types/request": "0.0.45",
9190
"@types/semver": "^5.3.31",
9291
"@types/source-map": "0.5.0",
93-
"chai": "3.5.0",
94-
"chai-as-promised": "6.0.0",
92+
"chai": "4.0.2",
93+
"chai-as-promised": "7.0.0",
9594
"grunt": "1.0.1",
9695
"grunt-contrib-clean": "1.0.0",
9796
"grunt-contrib-copy": "1.0.0",
9897
"grunt-contrib-watch": "1.0.0",
9998
"grunt-shell": "1.3.0",
100-
"grunt-ts": "6.0.0-beta.6",
101-
"grunt-tslint": "4.0.0",
99+
"grunt-ts": "6.0.0-beta.16",
100+
"grunt-tslint": "5.0.1",
102101
"istanbul": "0.4.5",
103102
"mocha": "3.1.2",
104103
"should": "7.0.2",
105104
"source-map-support": "^0.4.14",
106-
"tslint": "4.3.1",
107-
"typescript": "2.1.4"
105+
"tslint": "5.4.3",
106+
"typescript": "2.4.1"
108107
},
109108
"license": "Apache-2.0",
110109
"engines": {

test/ios-entitlements-service.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("IOSEntitlements Service Tests", () => {
2929
testInjector.register("errors", ErrorsLib.Errors);
3030

3131
testInjector.register("pluginsService", {
32-
getAllInstalledPlugins: async () => []
32+
getAllInstalledPlugins: async (): Promise<any[]> => []
3333
});
3434

3535
return testInjector;
@@ -137,8 +137,8 @@ describe("IOSEntitlements Service Tests", () => {
137137

138138
it("Merge uses the entitlements file from a Plugin", async () => {
139139
let pluginsService = injector.resolve("pluginsService");
140-
let testPluginFolderPath = temp.mkdirSync("testPlugin");
141-
pluginsService.getAllInstalledPlugins = async() => [{
140+
let testPluginFolderPath = temp.mkdirSync("testPlugin");
141+
pluginsService.getAllInstalledPlugins = async () => [{
142142
pluginPlatformsFolderPath: (platform: string) => {
143143
return testPluginFolderPath;
144144
}
@@ -161,8 +161,8 @@ describe("IOSEntitlements Service Tests", () => {
161161

162162
// setup plugin entitlements
163163
let pluginsService = injector.resolve("pluginsService");
164-
let testPluginFolderPath = temp.mkdirSync("testPlugin");
165-
pluginsService.getAllInstalledPlugins = async() => [{
164+
let testPluginFolderPath = temp.mkdirSync("testPlugin");
165+
pluginsService.getAllInstalledPlugins = async () => [{
166166
pluginPlatformsFolderPath: (platform: string) => {
167167
return testPluginFolderPath;
168168
}

0 commit comments

Comments
 (0)