Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit c752b38

Browse files
Fix PR comments
1 parent 97cbce9 commit c752b38

8 files changed

+36
-71
lines changed

declarations.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,6 @@ interface ICommonOptions {
967967
ddi: string; // the path to developer disk image
968968
justlaunch: boolean;
969969
skipRefresh: boolean;
970-
app: string;
971970
file: string;
972971
analyticsClient: string;
973972
force: boolean;

definitions/mobile.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ interface IIOSDeviceOperations extends IDisposable {
703703

704704
downloadFiles(deviceFilePaths: IOSDeviceLib.IFileOperationData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse>;
705705

706-
uploadFiles(files: IOSDeviceLib.IUploadFilesData[]): Promise<IOSDeviceLib.IDeviceResponse>[];
706+
uploadFiles(files: IOSDeviceLib.IUploadFilesData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse>;
707707

708708
deleteFiles(deleteArray: IOSDeviceLib.IDeleteFileData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse>;
709709

@@ -718,12 +718,7 @@ interface IIOSDeviceOperations extends IDisposable {
718718
setShouldDispose(shouldDispose: boolean): void;
719719
}
720720

721-
interface IDeviceOperationError {
722-
error: Error;
723-
deviceIdentifier: string;
724-
}
725-
726-
type DeviceOperationErrorHandler = (err: IDeviceOperationError) => void;
721+
type DeviceOperationErrorHandler = (err: IOSDeviceLib.IDeviceError) => void;
727722

728723
type DeviceInfoCallback = (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => void;
729724

definitions/plistlib.d.ts

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

mobile/ios/device/ios-application-manager.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export class IOSApplicationManager extends ApplicationManagerBase {
2727

2828
@hook('install')
2929
public async installApplication(packageFilePath: string): Promise<void> {
30-
await this.$iosDeviceOperations.install(packageFilePath, [this.device.deviceInfo.identifier], (err: IDeviceOperationError) => {
31-
this.$logger.warn(`Failed to install ${packageFilePath} on device with identifier ${err.deviceIdentifier}`);
30+
await this.$iosDeviceOperations.install(packageFilePath, [this.device.deviceInfo.identifier], (err: IOSDeviceLib.IDeviceError) => {
31+
this.$logger.warn(`Failed to install ${packageFilePath} on device with identifier ${err.deviceId}`);
3232
});
3333
}
3434

@@ -45,18 +45,13 @@ export class IOSApplicationManager extends ApplicationManagerBase {
4545
const applicationsOnDeviceInfo = _.first((await this.$iosDeviceOperations.apps([deviceIdentifier]))[deviceIdentifier]);
4646
const applicationsOnDevice = applicationsOnDeviceInfo ? applicationsOnDeviceInfo.response : [];
4747
this.$logger.trace("Result when getting applications for which LiveSync is enabled: ", JSON.stringify(applicationsOnDevice, null, 2));
48-
this.applicationsLiveSyncInfos = [];
49-
50-
const mappedApps = _.map(applicationsOnDevice, app => {
51-
return {
52-
applicationIdentifier: app.CFBundleIdentifier,
53-
isLiveSyncSupported: app.IceniumLiveSyncEnabled,
54-
configuration: app.configuration,
55-
deviceIdentifier: this.device.deviceInfo.identifier
56-
};
57-
});
5848

59-
this.applicationsLiveSyncInfos = this.applicationsLiveSyncInfos.concat(mappedApps);
49+
this.applicationsLiveSyncInfos = _.map(applicationsOnDevice, app => ({
50+
applicationIdentifier: app.CFBundleIdentifier,
51+
isLiveSyncSupported: app.IceniumLiveSyncEnabled,
52+
configuration: app.configuration,
53+
deviceIdentifier: this.device.deviceInfo.identifier
54+
}));
6055

6156
return this.applicationsLiveSyncInfos;
6257
}
@@ -71,16 +66,16 @@ export class IOSApplicationManager extends ApplicationManagerBase {
7166
}
7267

7368
public async uninstallApplication(appIdentifier: string): Promise<void> {
74-
await this.$iosDeviceOperations.uninstall(appIdentifier, [this.device.deviceInfo.identifier], (err: IDeviceOperationError) => {
75-
this.$logger.warn(`Failed to uninstall install ${appIdentifier} on device with identifier ${err.deviceIdentifier}`);
69+
await this.$iosDeviceOperations.uninstall(appIdentifier, [this.device.deviceInfo.identifier], (err: IOSDeviceLib.IDeviceError) => {
70+
this.$logger.warn(`Failed to uninstall ${appIdentifier} on device with identifier ${err.deviceId}`);
7671
});
7772

7873
this.$logger.trace("Application %s has been uninstalled successfully.", appIdentifier);
7974
}
8075

8176
public async startApplication(appIdentifier: string): Promise<void> {
8277
if (this.$hostInfo.isWindows && !this.$staticConfig.enableDeviceRunCommandOnWindows) {
83-
// this.$errors.fail("$%s device run command is not supported on Windows for iOS devices.", this.$staticConfig.CLIENT_NAME.toLowerCase());
78+
this.$errors.fail("$%s device run command is not supported on Windows for iOS devices.", this.$staticConfig.CLIENT_NAME.toLowerCase());
8479
}
8580

8681
if (!await this.isApplicationInstalled(appIdentifier)) {

mobile/ios/device/ios-device-file-system.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { EOL } from "os";
2-
import { settlePromises } from "../../../helpers";
32

43
export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
54
private static AFC_DELETE_FILE_NOT_FOUND_ERROR = 8;
@@ -40,12 +39,11 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
4039
}
4140

4241
public async deleteFile(deviceFilePath: string, appIdentifier: string): Promise<void> {
43-
await this.$iosDeviceOperations.deleteFiles([{ appId: appIdentifier, destination: deviceFilePath, deviceId: this.device.deviceInfo.identifier }], err => {
44-
const error = err.error;
45-
this.$logger.trace(`Error while deleting file: ${deviceFilePath}: ${error.message} with code: ${error.code}`);
42+
await this.$iosDeviceOperations.deleteFiles([{ appId: appIdentifier, destination: deviceFilePath, deviceId: this.device.deviceInfo.identifier }], (err: IOSDeviceLib.IDeviceError) => {
43+
this.$logger.trace(`Error while deleting file: ${deviceFilePath}: ${err.message} with code: ${err.code}`);
4644

47-
if (error.code !== IOSDeviceFileSystem.AFC_DELETE_FILE_NOT_FOUND_ERROR) {
48-
this.$logger.warn(`Cannot delete file: ${deviceFilePath}. Reason: ${error.message}`);
45+
if (err.code !== IOSDeviceFileSystem.AFC_DELETE_FILE_NOT_FOUND_ERROR) {
46+
this.$logger.warn(`Cannot delete file: ${deviceFilePath}. Reason: ${err.message}`);
4947
}
5048
});
5149
}
@@ -68,12 +66,10 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
6866
}
6967

7068
private async uploadFilesCore(filesToUpload: IOSDeviceLib.IUploadFilesData[]): Promise<void> {
71-
try {
72-
await settlePromises(await this.$iosDeviceOperations.uploadFiles(filesToUpload));
73-
} catch (err) {
69+
await this.$iosDeviceOperations.uploadFiles(filesToUpload, (err: IOSDeviceLib.IDeviceError) => {
7470
if (err.deviceId === this.device.deviceInfo.identifier) {
7571
throw err;
7672
}
77-
}
73+
});
7874
}
7975
}

mobile/ios/device/ios-device-operations.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
1515
public async install(ipaPath: string, deviceIdentifiers: string[], errorHandler: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
1616
this.assertIsInitialized();
1717
this.$logger.trace(`Installing ${ipaPath} on devices with identifiers: ${deviceIdentifiers}.`);
18-
return await this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.install(ipaPath, deviceIdentifiers), deviceIdentifiers, errorHandler);
18+
return await this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.install(ipaPath, deviceIdentifiers), errorHandler);
1919
}
2020

2121
public async uninstall(appIdentifier: string, deviceIdentifiers: string[], errorHandler: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
2222
this.assertIsInitialized();
2323
this.$logger.trace(`Uninstalling ${appIdentifier} from devices with identifiers: ${deviceIdentifiers}.`);
24-
return await this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.uninstall(appIdentifier, deviceIdentifiers), deviceIdentifiers, errorHandler);
24+
return await this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.uninstall(appIdentifier, deviceIdentifiers), errorHandler);
2525
}
2626

2727
@cache()
@@ -38,7 +38,6 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
3838
}
3939
}
4040

41-
@cache()
4241
public startDeviceLog(deviceIdentifier: string, printLogFunction: (data: string) => void): void {
4342
this.assertIsInitialized();
4443
this.setShouldDispose(false);
@@ -55,7 +54,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
5554
public async apps(deviceIdentifiers: string[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceAppInfo> {
5655
this.assertIsInitialized();
5756
this.$logger.trace(`Getting applications information for devices with identifiers: ${deviceIdentifiers}`);
58-
return this.getMultipleResults(() => this.deviceLib.apps(deviceIdentifiers), deviceIdentifiers, errorHandler);
57+
return this.getMultipleResults(() => this.deviceLib.apps(deviceIdentifiers), errorHandler);
5958
}
6059

6160
public async listDirectory(listArray: IOSDeviceLib.IReadOperationData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceMultipleResponse> {
@@ -65,7 +64,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
6564
this.$logger.trace(`Listing directory: ${l.path} for application ${l.appId} on device with identifier: ${l.deviceId}.`);
6665
});
6766

68-
return this.getMultipleResults<IOSDeviceLib.IDeviceMultipleResponse>(() => this.deviceLib.list(listArray), this.getDeviceIdentifiersArray(listArray), errorHandler);
67+
return this.getMultipleResults<IOSDeviceLib.IDeviceMultipleResponse>(() => this.deviceLib.list(listArray), errorHandler);
6968
}
7069

7170
public async readFiles(deviceFilePaths: IOSDeviceLib.IReadOperationData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
@@ -75,7 +74,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
7574
this.$logger.trace(`Reading file: ${p.path} from application ${p.appId} on device with identifier: ${p.deviceId}.`);
7675
});
7776

78-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.read(deviceFilePaths), this.getDeviceIdentifiersArray(deviceFilePaths), errorHandler);
77+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.read(deviceFilePaths), errorHandler);
7978
}
8079

8180
public async downloadFiles(deviceFilePaths: IOSDeviceLib.IFileOperationData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
@@ -85,10 +84,10 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
8584
this.$logger.trace(`Downloading file: ${d.source} from application ${d.appId} on device with identifier: ${d.deviceId} to ${d.destination}.`);
8685
});
8786

88-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.download(deviceFilePaths), this.getDeviceIdentifiersArray(deviceFilePaths), errorHandler);
87+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.download(deviceFilePaths), errorHandler);
8988
}
9089

91-
public uploadFiles(files: IOSDeviceLib.IUploadFilesData[]): Promise<IOSDeviceLib.IDeviceResponse>[] {
90+
public uploadFiles(files: IOSDeviceLib.IUploadFilesData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
9291
this.assertIsInitialized();
9392

9493
_.each(files, f => {
@@ -97,7 +96,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
9796
this.$logger.trace(`For application ${f.appId} on device with identifier: ${f.deviceId}.`);
9897
});
9998

100-
return this.deviceLib.upload(files);
99+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.upload(files), errorHandler);
101100
}
102101

103102
public async deleteFiles(deleteArray: IOSDeviceLib.IDeleteFileData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
@@ -107,7 +106,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
107106
this.$logger.trace(`Deleting file: ${d.destination} from application ${d.appId} on device with identifier: ${d.deviceId}.`);
108107
});
109108

110-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.delete(deleteArray), this.getDeviceIdentifiersArray(deleteArray), errorHandler);
109+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.delete(deleteArray), errorHandler);
111110
}
112111

113112
public async start(startArray: IOSDeviceLib.IDdiApplicationData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
@@ -117,7 +116,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
117116
this.$logger.trace(`Starting application ${s.appId} on device with identifier: ${s.deviceId}.`);
118117
});
119118

120-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.start(startArray), this.getDeviceIdentifiersArray(startArray), errorHandler);
119+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.start(startArray), errorHandler);
121120
}
122121

123122
public async stop(stopArray: IOSDeviceLib.IDdiApplicationData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
@@ -127,7 +126,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
127126
this.$logger.trace(`Stopping application ${s.appId} on device with identifier: ${s.deviceId}.`);
128127
});
129128

130-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.start(stopArray), this.getDeviceIdentifiersArray(stopArray), errorHandler);
129+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.start(stopArray), errorHandler);
131130
}
132131

133132
public dispose(signal?: string): void {
@@ -147,7 +146,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
147146
this.$logger.trace(`Sending notification ${n.notificationName} to device with identifier: ${n.deviceId}`);
148147
});
149148

150-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.notify(notifyArray), this.getDeviceIdentifiersArray(notifyArray), errorHandler);
149+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.notify(notifyArray), errorHandler);
151150
}
152151

153152
public async connectToPort(connectToPortArray: IOSDeviceLib.IConnectToPortData[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {
@@ -157,26 +156,24 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
157156
this.$logger.trace(`Connecting to port ${c.port} on device with identifier: ${c.deviceId}`);
158157
});
159158

160-
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.connectToPort(connectToPortArray), this.getDeviceIdentifiersArray(connectToPortArray), errorHandler);
159+
return this.getMultipleResults<IOSDeviceLib.IDeviceResponse>(() => this.deviceLib.connectToPort(connectToPortArray), errorHandler);
161160
}
162161

163162
public setShouldDispose(shouldDispose: boolean): void {
164163
this.shouldDispose = shouldDispose;
165164
}
166165

167-
private async getMultipleResults<T>(getPromisesMethod: () => Promise<T>[], deviceIdentifiers: string[], errorHandler?: DeviceOperationErrorHandler): Promise<IDictionary<T[]>> {
166+
private async getMultipleResults<T>(getPromisesMethod: () => Promise<T>[], errorHandler?: DeviceOperationErrorHandler): Promise<IDictionary<T[]>> {
168167
const result: T[] = [];
169168
const promises = getPromisesMethod();
170169

171-
for (let i = 0; i < promises.length; i++) {
172-
const promise = promises[i];
173-
170+
for (let promise of promises) {
174171
if (errorHandler) {
175172
try {
176173
result.push(await promise);
177174
} catch (err) {
178175
this.$logger.trace(`Error while executing ios device operation: ${err.message} with code: ${err.code}`);
179-
errorHandler({ error: err, deviceIdentifier: deviceIdentifiers[i] });
176+
errorHandler(err);
180177
}
181178
} else {
182179
result.push(await promise);
@@ -186,10 +183,6 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
186183
return _.groupBy(result, r => (<any>r).deviceId);
187184
}
188185

189-
private getDeviceIdentifiersArray(deviceInformation: IOSDeviceLib.IDeviceId[]): string[] {
190-
return _.map(deviceInformation, d => d.deviceId);
191-
}
192-
193186
private assertIsInitialized(): void {
194187
assert.ok(this.isInitialized, "iOS device operations not initialized.");
195188
}

mobile/ios/device/ios-device.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import * as constants from "../../../constants";
44
import * as net from "net";
55

66
export class IOSDevice implements Mobile.IiOSDevice {
7-
// iOS errors are described here with HEX representation
8-
// https://github.com/samdmarshall/SDMMobileDevice/blob/763fa8d5a3b72eea86bf854894f8c8bcf5676877/Framework/MobileDevice/Error/SDMMD_Error.h
9-
// We receive them as decimal values.
10-
117
public applicationManager: Mobile.IDeviceApplicationManager;
128
public fileSystem: Mobile.IDeviceFileSystem;
139
public deviceInfo: Mobile.IDeviceInfo;
@@ -53,7 +49,7 @@ export class IOSDevice implements Mobile.IiOSDevice {
5349

5450
public async openDeviceLogStream(): Promise<void> {
5551
if (this.deviceInfo.status !== constants.UNREACHABLE_STATUS) {
56-
await this.$iosDeviceOperations.startDeviceLog(this.deviceInfo.identifier, (data: string) => {
52+
this.$iosDeviceOperations.startDeviceLog(this.deviceInfo.identifier, (data: string) => {
5753
this.$deviceLogProvider.logData(data, this.$devicePlatformsConstants.iOS, this.deviceInfo.identifier);
5854
});
5955
}

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"colors": "0.6.2",
3434
"cookie": "0.1.0",
3535
"esprima": "2.7.0",
36-
"ffi": "https://github.com/icenium/node-ffi/tarball/v2.0.0.4",
3736
"filesize": "2.0.3",
3837
"gaze": "1.0.0",
3938
"iconv-lite": "0.4.3",
@@ -52,12 +51,9 @@
5251
"osenv": "0.1.0",
5352
"parse5": "2.2.0",
5453
"plist": "1.1.0",
55-
"plistlib": "0.2.1",
5654
"progress-stream": "0.5.0",
5755
"properties-parser": "0.2.3",
5856
"pullstream": "https://github.com/icenium/node-pullstream/tarball/master",
59-
"ref": "https://github.com/icenium/ref/tarball/v1.3.2.2",
60-
"ref-struct": "https://github.com/telerik/ref-struct/tarball/v1.0.2.4",
6157
"rimraf": "2.2.6",
6258
"semver": "4.3.4",
6359
"shelljs": "0.7.5",

0 commit comments

Comments
 (0)