Skip to content

Commit c462700

Browse files
chore: remove mobile-platform-capabilities
In older implementation there was a requirement to have different capabilities for each platform (Android, iOS, WP8) like deploy via cable, deploy over wi-fi with companion app, etc. This code is no longer used, so delete the capabilities implementation from the codebase.
1 parent 687a02b commit c462700

16 files changed

+5
-190
lines changed

lib/bootstrap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ $injector.requireCommand("package-manager|get", "./commands/package-manager-get"
8787

8888
$injector.require("packageInstallationManager", "./package-installation-manager");
8989
$injector.require("dynamicHelpProvider", "./dynamic-help-provider");
90-
$injector.require("mobilePlatformsCapabilities", "./mobile-platforms-capabilities");
9190
$injector.require("commandsServiceProvider", "./providers/commands-service-provider");
9291
$injector.require("AppDataProvider", "./providers/device-app-data-provider");
9392

lib/common/declarations.d.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,6 @@ interface IPlaygroundInfo {
781781
usedTutorial: boolean;
782782
}
783783

784-
interface IHostCapabilities {
785-
capabilities: IDictionary<IHostCapability>;
786-
}
787-
788-
interface IHostCapability {
789-
debugToolsSupported: boolean;
790-
}
791-
792784
interface IAutoCompletionService {
793785

794786
/**

lib/common/definitions/mobile.d.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,6 @@ declare module Mobile {
663663
create(fileName: string, localProjectRootPath: string, onDeviceFileName: string, deviceProjectRootPath: string): Mobile.ILocalToDevicePathData;
664664
}
665665

666-
// TODO: Remove
667-
interface IPlatformCapabilities {
668-
wirelessDeploy?: boolean;
669-
cableDeploy: boolean;
670-
companion?: boolean;
671-
hostPlatformsForDeploy: string[];
672-
}
673666
interface IAvdInfo extends IDictionary<string | number> {
674667
target: string;
675668
targetNum: number;
@@ -1009,20 +1002,13 @@ declare module Mobile {
10091002
timeout?: number;
10101003
}
10111004

1012-
// TODO: Consider removing
1013-
interface IPlatformsCapabilities {
1014-
getPlatformNames(): string[];
1015-
getAllCapabilities(): IDictionary<Mobile.IPlatformCapabilities>;
1016-
}
10171005
interface IMobileHelper {
10181006
platformNames: string[];
10191007
isAndroidPlatform(platform: string): boolean;
10201008
isiOSPlatform(platform: string): boolean;
10211009
isWP8Platform(platform: string): boolean;
10221010
normalizePlatformName(platform: string): string;
1023-
isPlatformSupported(platform: string): boolean;
10241011
validatePlatformName(platform: string): string;
1025-
getPlatformCapabilities(platform: string): Mobile.IPlatformCapabilities;
10261012
buildDevicePath(...args: string[]): string;
10271013
correctDevicePath(filePath: string): string;
10281014
isiOSTablet(deviceName: string): boolean;

lib/common/mobile/mobile-core/devices-service.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
1515
private static DEVICE_LOOKING_INTERVAL = 200;
1616
private _devices: IDictionary<Mobile.IDevice> = {};
1717
private _availableEmulators: IDictionary<Mobile.IDeviceInfo> = {};
18-
private platforms: string[] = [];
1918
private _platform: string;
2019
private _device: Mobile.IDevice;
2120
private _isInitialized = false;
@@ -201,26 +200,6 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
201200
return _.values(this._devices);
202201
}
203202

204-
private getAllPlatforms(): Array<string> {
205-
if (this.platforms.length > 0) {
206-
return this.platforms;
207-
}
208-
209-
this.platforms = _.filter(this.$mobileHelper.platformNames, platform => this.$mobileHelper.getPlatformCapabilities(platform).cableDeploy);
210-
return this.platforms;
211-
}
212-
213-
private getPlatform(platform: string): string {
214-
const allSupportedPlatforms = this.getAllPlatforms();
215-
const normalizedPlatform = this.$mobileHelper.validatePlatformName(platform);
216-
if (!_.includes(allSupportedPlatforms, normalizedPlatform)) {
217-
this.$errors.failWithoutHelp("Deploying to %s connected devices is not supported. Build the " +
218-
"app using the `build` command and deploy the package manually.", normalizedPlatform);
219-
}
220-
221-
return normalizedPlatform;
222-
}
223-
224203
@exported("devicesService")
225204
public async getInstalledApplications(deviceIdentifier: string): Promise<string[]> {
226205
const device = await this.getDevice(deviceIdentifier);
@@ -618,7 +597,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
618597
const deviceOption = deviceInitOpts.deviceId;
619598

620599
if (platform && deviceOption) {
621-
this._platform = this.getPlatform(deviceInitOpts.platform);
600+
this._platform = this.$mobileHelper.validatePlatformName(deviceInitOpts.platform);
622601
await this.startLookingForDevices(deviceInitOpts);
623602
this._device = await this.getDevice(deviceOption);
624603
if (this._device.deviceInfo.platform !== this._platform) {
@@ -630,7 +609,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
630609
this._device = await this.getDevice(deviceOption);
631610
this._platform = this._device.deviceInfo.platform;
632611
} else if (platform && !deviceOption) {
633-
this._platform = this.getPlatform(platform);
612+
this._platform = this.$mobileHelper.validatePlatformName(platform);
634613
await this.startLookingForDevices(deviceInitOpts);
635614
} else {
636615
// platform and deviceId are not specified
@@ -649,7 +628,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
649628
.map(device => device.deviceInfo.platform)
650629
.filter(pl => {
651630
try {
652-
return this.getPlatform(pl);
631+
return this.$mobileHelper.validatePlatformName(pl);
653632
} catch (err) {
654633
this.$logger.warn(err.message);
655634
return null;

lib/common/mobile/mobile-helper.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,12 @@ import * as helpers from "../helpers";
22

33
export class MobileHelper implements Mobile.IMobileHelper {
44
private static DEVICE_PATH_SEPARATOR = "/";
5-
private platformNamesCache: string[];
65

7-
constructor(private $mobilePlatformsCapabilities: Mobile.IPlatformsCapabilities,
8-
private $errors: IErrors,
6+
constructor(private $errors: IErrors,
97
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) { }
108

119
public get platformNames(): string[] {
12-
this.platformNamesCache = this.platformNamesCache ||
13-
_.map(this.$mobilePlatformsCapabilities.getPlatformNames(), platform => this.normalizePlatformName(platform));
14-
15-
return this.platformNamesCache;
16-
}
17-
18-
public getPlatformCapabilities(platform: string): Mobile.IPlatformCapabilities {
19-
const platformNames = this.$mobilePlatformsCapabilities.getPlatformNames();
20-
const validPlatformName = this.validatePlatformName(platform);
21-
if (!_.some(platformNames, platformName => platformName === validPlatformName)) {
22-
this.$errors.failWithoutHelp("'%s' is not a valid device platform. Valid platforms are %s.", platform, platformNames);
23-
}
24-
25-
return this.$mobilePlatformsCapabilities.getAllCapabilities()[validPlatformName];
10+
return [this.$devicePlatformsConstants.iOS, this.$devicePlatformsConstants.Android];
2611
}
2712

2813
public isAndroidPlatform(platform: string): boolean {
@@ -49,10 +34,6 @@ export class MobileHelper implements Mobile.IMobileHelper {
4934
return undefined;
5035
}
5136

52-
public isPlatformSupported(platform: string): boolean {
53-
return _.includes(this.getPlatformCapabilities(platform).hostPlatformsForDeploy, process.platform);
54-
}
55-
5637
public validatePlatformName(platform: string): string {
5738
if (!platform) {
5839
this.$errors.fail("No device platform specified.");

lib/common/test/unit-tests/mobile/android-device-file-system.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,6 @@ class LocalToDevicePathDataMock {
4747
}
4848
}
4949

50-
class MobilePlatformsCapabilitiesMock implements Mobile.IPlatformsCapabilities {
51-
public getPlatformNames(): string[] {
52-
return _.keys(this.getAllCapabilities());
53-
}
54-
55-
public getAllCapabilities(): IDictionary<Mobile.IPlatformCapabilities> {
56-
return {
57-
iOS: {
58-
"wirelessDeploy": false,
59-
"cableDeploy": true,
60-
"companion": false,
61-
"hostPlatformsForDeploy": ["darwin"]
62-
},
63-
Android: {
64-
"wirelessDeploy": false,
65-
"cableDeploy": true,
66-
"companion": false,
67-
"hostPlatformsForDeploy": ["win32", "darwin", "linux"]
68-
}
69-
};
70-
}
71-
}
72-
7350
function mockFsStats(options: { isDirectory: boolean, isFile: boolean }): (filePath: string) => { isDirectory: () => boolean, isFile: () => boolean } {
7451
return (filePath: string) => ({
7552
isDirectory: (): boolean => options.isDirectory,
@@ -85,7 +62,6 @@ function createTestInjector(): IInjector {
8562
injector.register("config", {});
8663
injector.register("options", {});
8764
injector.register("errors", Errors);
88-
injector.register("mobilePlatformsCapabilities", MobilePlatformsCapabilitiesMock);
8965
injector.register("devicePlatformsConstants", DevicePlatformsConstants);
9066
injector.register("projectFilesManager", {});
9167

lib/common/test/unit-tests/mobile/devices-service.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,6 @@ describe("devicesService", () => {
669669
await assert.isRejected(devicesService.initialize({ platform: "android", deviceId: androidDevice.deviceInfo.identifier }), expectedErrorMessage);
670670
});
671671

672-
it("when initialize is called with deviceId and invalid platform", async () => {
673-
assert.isFalse(devicesService.hasDevices, "Initially devicesService hasDevices must be false.");
674-
iOSDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, iOSDevice);
675-
androidDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, androidDevice);
676-
await assert.isRejected(devicesService.initialize({ platform: "invalidPlatform", deviceId: androidDevice.deviceInfo.identifier }), "Deploying to %s connected devices is not supported. Build the app using the `build` command and deploy the package manually.");
677-
});
678-
679672
it("when initialize is called with platform and deviceId and device's platform is different", async () => {
680673
assert.isFalse(devicesService.hasDevices, "Initially devicesService hasDevices must be false.");
681674
iOSDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, iOSDevice);
@@ -890,32 +883,6 @@ describe("devicesService", () => {
890883
await assert.isRejected(devicesService.initialize(), "Multiple device platforms detected (android and ios). Specify platform or device on command line.");
891884
});
892885

893-
it("when parameters are not passed and devices with invalid platforms are detected initialize should work with correct devices only", async () => {
894-
assert.isFalse(devicesService.hasDevices, "Initially devicesService hasDevices must be false.");
895-
androidDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, androidDevice);
896-
iOSDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, {
897-
deviceInfo: {
898-
identifier: "invalid-platform-device",
899-
platform: "invalid-platform"
900-
}
901-
});
902-
903-
await devicesService.initialize();
904-
905-
assert.isTrue(logger.output.indexOf("is not supported") !== -1);
906-
});
907-
908-
it("when parameters are not passed and only devices with invalid platforms are detected, initialize should throw", async () => {
909-
assert.isFalse(devicesService.hasDevices, "Initially devicesService hasDevices must be false.");
910-
iOSDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, {
911-
deviceInfo: {
912-
identifier: "invalid-platform-device",
913-
platform: "invalid-platform"
914-
}
915-
});
916-
await assert.isRejected(devicesService.initialize(), constants.ERROR_NO_DEVICES);
917-
});
918-
919886
it("caches execution result and does not execute next time when called", async () => {
920887
assert.isFalse(devicesService.hasDevices, "Initially devicesService hasDevices must be false.");
921888
androidDeviceDiscovery.emit(DeviceDiscoveryEventNames.DEVICE_FOUND, androidDevice);

lib/common/test/unit-tests/mobile/project-files-manager.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,6 @@ const iOSDeviceAppData: Mobile.IDeviceAppData = <any>{
3232
getDeviceProjectRootPath: async () => iOSDeviceProjectRootPath,
3333
};
3434

35-
class MobilePlatformsCapabilitiesMock implements Mobile.IPlatformsCapabilities {
36-
public getPlatformNames(): string[] {
37-
return _.keys(this.getAllCapabilities());
38-
}
39-
40-
public getAllCapabilities(): IDictionary<Mobile.IPlatformCapabilities> {
41-
return {
42-
iOS: {
43-
wirelessDeploy: false,
44-
cableDeploy: true,
45-
companion: false,
46-
hostPlatformsForDeploy: ["darwin"]
47-
},
48-
Android: {
49-
wirelessDeploy: false,
50-
cableDeploy: true,
51-
companion: false,
52-
hostPlatformsForDeploy: ["win32", "darwin", "linux"]
53-
}
54-
};
55-
}
56-
}
57-
5835
function createTestInjector(): IInjector {
5936
const testInjector = new Yok();
6037

@@ -64,7 +41,6 @@ function createTestInjector(): IInjector {
6441
testInjector.register("hostInfo", HostInfo);
6542
testInjector.register("localToDevicePathDataFactory", LocalToDevicePathDataFactory);
6643
testInjector.register("mobileHelper", MobileHelper);
67-
testInjector.register("mobilePlatformsCapabilities", MobilePlatformsCapabilitiesMock);
6844
testInjector.register("projectFilesProvider", ProjectFilesProviderBase);
6945
testInjector.register("projectFilesManager", ProjectFilesManager);
7046
testInjector.register("options", {});

lib/mobile-platforms-capabilities.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/ios-entitlements-service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { IOSEntitlementsService } from "../lib/services/ios-entitlements-service
55
import * as yok from "../lib/common/yok";
66
import * as stubs from "./stubs";
77
import * as FsLib from "../lib/common/file-system";
8-
import * as MobilePlatformsCapabilitiesLib from "../lib/mobile-platforms-capabilities";
98
import * as MobileHelperLib from "../lib/common/mobile/mobile-helper";
109
import * as DevicePlatformsConstantsLib from "../lib/common/mobile/device-platforms-constants";
1110
import * as ErrorsLib from "../lib/common/errors";
@@ -26,7 +25,6 @@ describe("IOSEntitlements Service Tests", () => {
2625
testInjector.register("fs", FsLib.FileSystem);
2726
testInjector.register("mobileHelper", MobileHelperLib.MobileHelper);
2827
testInjector.register("devicePlatformsConstants", DevicePlatformsConstantsLib.DevicePlatformsConstants);
29-
testInjector.register("mobilePlatformsCapabilities", MobilePlatformsCapabilitiesLib.MobilePlatformsCapabilities);
3028
testInjector.register("errors", ErrorsLib.Errors);
3129

3230
testInjector.register("pluginsService", {

0 commit comments

Comments
 (0)