Skip to content

Commit d15f587

Browse files
Fatme HavaluovaFatme Havaluova
authored andcommitted
Support for xcode7 simulator
1 parent 3685d20 commit d15f587

11 files changed

+759
-350
lines changed

lib/child-process.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
///<reference path="./.d.ts"/>
2+
"use strict";
3+
4+
import child_process = require("child_process");
5+
import errors = require("./errors");
6+
import Future = require("fibers/future");
7+
import util = require("util");
8+
9+
export function exec(command: string): IFuture<any> {
10+
var future = new Future<any>();
11+
12+
child_process.exec(command, (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) => {
13+
//console.log(util.format("Executing: %s", command));
14+
15+
if(error) {
16+
errors.fail(util.format("Error %s while executing %s.", error.message, command));
17+
} else {
18+
future.return(stdout ? stdout.toString() : "");
19+
}
20+
});
21+
22+
return future;
23+
}
24+
25+
export function spawn(command: string, args: string[]): IFuture<string> {
26+
let future = new Future<string>();
27+
let capturedOut = "";
28+
let capturedErr = "";
29+
30+
let childProcess = child_process.spawn(command, args);
31+
32+
if(childProcess.stdout) {
33+
childProcess.stdout.on("data", (data: string) => {
34+
capturedOut += data;
35+
});
36+
}
37+
38+
if(childProcess.stderr) {
39+
childProcess.stderr.on("data", (data: string) => {
40+
capturedErr += data;
41+
});
42+
}
43+
44+
childProcess.on("close", (arg: any) => {
45+
var exitCode = typeof arg == 'number' ? arg : arg && arg.code;
46+
if(exitCode === 0) {
47+
future.return(capturedOut ? capturedOut.trim() : null);
48+
} else {
49+
future.throw(util.format("Command %s with arguments %s failed with exit code %s. Error output: \n %s", command, args.join(" "), exitCode, capturedErr));
50+
}
51+
});
52+
53+
return future;
54+
}

lib/commands/launch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import iphoneSimulatorLibPath = require("./../iphone-simulator");
77
export class Command implements ICommand {
88
public execute(args: string[]): IFuture<void> {
99
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
10-
return iphoneSimulator.run(args[0]);
10+
return iphoneSimulator.run(args[0], args[1]);
1111
}
1212
}

lib/declarations.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"use strict";
33

44
interface IiPhoneSimulator {
5-
run(appName: string): IFuture<void>;
5+
run(applicationPath: string, applicationIdentifier: string): IFuture<void>;
66
printDeviceTypes(): IFuture<void>;
77
printSDKS(): IFuture<void>;
88
sendNotification(notification: string): IFuture<void>;
@@ -17,22 +17,38 @@ interface ICommandExecutor {
1717
}
1818

1919
interface IDevice {
20-
device: any; // nodobjc wrapper to device
21-
deviceIdentifier: string;
22-
fullDeviceIdentifier: string;
20+
name: string;
21+
id: string;
22+
fullId: string;
2323
runtimeVersion: string;
24+
state?: string;
25+
rawDevice?: any; // NodObjC wrapper to device
26+
}
27+
28+
interface ISimctl {
29+
launch(deviceId: string, applicationIdentifier: string): IFuture<void>;
30+
install(deviceId: string, applicationPath: string): IFuture<void>;
31+
uninstall(deviceId: string, applicationIdentifier: string): IFuture<void>;
32+
notifyPost(deviceId: string, notification: string): IFuture<void>;
33+
getDevices(): IFuture<IDevice[]>;
2434
}
2535

2636
interface IDictionary<T> {
2737
[key: string]: T;
2838
}
2939

30-
interface ISimulator {
31-
validDeviceIdentifiers: string[];
32-
deviceIdentifiersInfo: string[];
40+
interface IInteropSimulator {
41+
getDevices(): IFuture<IDevice[]>;
3342
setSimulatedDevice(config: any): void;
3443
}
3544

45+
interface ISimulator {
46+
getDevices(): IFuture<IDevice[]>;
47+
getSdks(): IFuture<ISdk[]>;
48+
run(applicationPath: string, applicationIdentifier: string): IFuture<void>;
49+
sendNotification(notification: string): IFuture<void>;
50+
}
51+
3652
interface IExecuteOptions {
3753
canRunMainLoop: boolean;
3854
appPath?: string;
@@ -42,5 +58,10 @@ interface ISdk {
4258
displayName: string;
4359
version: string;
4460
rootPath: string;
45-
sdkInfo(): string;
61+
}
62+
63+
interface IXcodeVersionData {
64+
major: string;
65+
minor: string;
66+
build: string;
4667
}

0 commit comments

Comments
 (0)