Skip to content

Commit 45740a4

Browse files
FatmeFatme
authored andcommitted
Merge pull request #1 from telerik/fatme/ios-sim
Launch iOS simulator
2 parents c61fa1c + becb9ba commit 45740a4

15 files changed

+4751
-6
lines changed

.gitignore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ lib-cov
1111
*.out
1212
*.pid
1313
*.gz
14-
*.tgz
15-
*.tmp
14+
*.tgz
15+
*.tmp
1616
tscommand*.tmp.txt
1717
.tscache/
1818
/lib/.d.ts
19-
20-
.idea/
19+
20+
.idea/
2121

2222
test-reports.xml
2323

24-
npm-debug.log
25-
node_modules
24+
npm-debug.log
25+
node_modules

Gruntfile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = function(grunt) {
2+
grunt.initConfig({
3+
pkg: grunt.file.readJSON("package.json"),
4+
ts: {
5+
options: {
6+
target: 'es5',
7+
module: 'commonjs',
8+
sourceMap: true,
9+
declaration: false,
10+
removeComments: false,
11+
noImplicitAny: true
12+
},
13+
devlib: {
14+
src: ["lib/**/*.ts"],
15+
reference: "lib/.d.ts"
16+
}
17+
}
18+
});
19+
20+
grunt.loadNpmTasks("grunt-ts");
21+
22+
grunt.registerTask("default", "ts:devlib");
23+
}

bin/ios-sim-portable

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require("../lib/ios-sim.js");

bin/ios-sim-portable.cmd

Whitespace-only changes.

lib/command-executor.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
///<reference path="./.d.ts"/>
2+
"use strict";
3+
4+
import util = require("util");
5+
import options = require("./options");
6+
7+
export class CommandExecutor implements ICommandExecutor {
8+
9+
public execute(): IFuture<void> {
10+
var commandName = this.getCommandName();
11+
var commandArguments = this.getCommandArguments();
12+
13+
return this.executeCore(commandName, commandArguments);
14+
}
15+
16+
private executeCore(commandName: string, commandArguments: string[]): IFuture<void> {
17+
var command = new (require("./commands/" + commandName).Command)();
18+
if(!command) {
19+
throw new Error(util.format("Unable to resolve commandName %s", commandName));
20+
}
21+
22+
return command.execute(commandArguments);
23+
}
24+
25+
private getCommandArguments(): string[] {
26+
var remaining = options._;
27+
return remaining.length > 1 ? remaining.slice(1): [];
28+
}
29+
30+
private getCommandName(): string {
31+
var remaining = options._;
32+
return remaining.length > 0 ? remaining[0].toLowerCase() : "help";
33+
}
34+
}

lib/commands/launch.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path=".././.d.ts"/>
2+
"use strict";
3+
4+
import Future = require("fibers/future");
5+
import iphoneSimulatorLibPath = require("./../iphone-simulator");
6+
7+
export class Command implements ICommand {
8+
public execute(args: string[]): IFuture<void> {
9+
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
10+
return iphoneSimulator.run(args[0]);
11+
}
12+
}

lib/declarations.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
///<reference path="./.d.ts"/>
2+
"use strict";
3+
4+
interface IiPhoneSimulator {
5+
run(appName: string): IFuture<void>;
6+
}
7+
8+
interface ICommand {
9+
execute(args: string[]): IFuture<void>;
10+
}
11+
12+
interface ICommandExecutor {
13+
execute(): IFuture<void>;
14+
}

lib/definitions/NodObjC.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
declare module "NodObjC" {
2+
export function importFramework(frameworkName: string): void;
3+
export var classDefinition: IClass;
4+
5+
export var NSObject: INSObject;
6+
export var NSString: INSString;
7+
export var NSNumber: INSNumber;
8+
export var NSBundle: INSBundle;
9+
export var NSAutoreleasePool: INSAutoreleasePool;
10+
export var NSRunLoop: INSRunLoop;
11+
12+
interface IClass {
13+
getClassByName(className: string): any;
14+
}
15+
16+
interface INSObjectBase {
17+
(functionName: string, ...args: any[]): any;
18+
}
19+
20+
interface INSObject extends INSObjectBase {
21+
extend(className: string): any;
22+
}
23+
24+
interface INSString extends INSObjectBase { }
25+
26+
interface INSNumber extends INSObjectBase { }
27+
28+
interface INSBundle extends INSObjectBase { }
29+
30+
interface INSAutoreleasePool extends INSObjectBase { }
31+
32+
interface INSRunLoop extends INSObjectBase { }
33+
}

lib/definitions/node-fibers.d.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Type definitions for node-fibers
2+
// Project: https://github.com/laverdet/node-fibers
3+
// Definitions by: Cary Haynie <https://github.com/caryhaynie>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
interface Fiber {
7+
reset: () => any;
8+
run: (param?: any) => any;
9+
throwInto: (ex: any) => any;
10+
}
11+
12+
interface IFuture<T> {
13+
detach(): void;
14+
get(): T;
15+
isResolved (): boolean;
16+
proxy<U>(future: IFuture<U>): void;
17+
proxyErrors(future: IFuture<any>): IFuture<T>;
18+
proxyErrors(futureList: IFuture<any>[]): IFuture<T>;
19+
resolver(): Function;
20+
resolve(fn: (err: any, result?: T) => void): void;
21+
resolveSuccess(fn: (result: T) => void): void;
22+
return(result?: T): void;
23+
throw(error: any): void;
24+
wait(): T;
25+
}
26+
27+
declare module "fibers" {
28+
29+
function Fiber(fn: Function): Fiber;
30+
31+
module Fiber {
32+
export var current: Fiber;
33+
export function yield(value?: any): any
34+
}
35+
36+
export = Fiber;
37+
}
38+
39+
interface ICallableFuture<T> {
40+
(...args: any[]): IFuture<T>;
41+
}
42+
43+
interface IFutureFactory<T> {
44+
(): IFuture<T>;
45+
}
46+
47+
interface Function {
48+
future<T>(...args: any[]): IFutureFactory<T>;
49+
}
50+
51+
declare module "fibers/future" {
52+
53+
class Future<T> implements IFuture<T> {
54+
constructor();
55+
detach(): void;
56+
get(): T;
57+
isResolved (): boolean;
58+
proxy<U>(future: IFuture<U>): void;
59+
proxyErrors(future: IFuture<any>): IFuture<T>;
60+
proxyErrors(futureList: IFuture<any>[]): IFuture<T>;
61+
resolver(): Function;
62+
resolve(fn: Function): void;
63+
resolveSuccess(fn: Function): void;
64+
return(result?: T): void;
65+
throw (error: any): void;
66+
wait(): T;
67+
68+
static wait<T>(future: IFuture<T>): void;
69+
static wait(future_list: IFuture<any>[]): void;
70+
static wait(...future_list: IFuture<any>[]): void;
71+
72+
static settle<T>(future: IFuture<T>): void;
73+
static settle(future_list: IFuture<any>[]): void;
74+
static settle(...future_list: IFuture<any>[]): void;
75+
76+
static wrap<T>(fn: (callback: (error: Error, result: T) => void) => void): ICallableFuture<T>;
77+
static wrap<T>(fn: (a: any, callback: (error: Error, result: T) => void) => void): ICallableFuture<T>;
78+
static wrap<T>(fn: (a: any, b: any, callback: (error: Error, result: T) => void) => void): ICallableFuture<T>;
79+
80+
static fromResult<T>(value: T): IFuture<T>;
81+
static fromResult(): IFuture<void>;
82+
83+
static assertNoFutureLeftBehind(): void;
84+
}
85+
86+
export = Future;
87+
}

0 commit comments

Comments
 (0)