Skip to content

Commit b056dba

Browse files
committed
Create project command
1 parent 38e5245 commit b056dba

15 files changed

+268
-16
lines changed

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,8 @@ pids
2323
logs
2424
results
2525
scratch/
26-
.idea/workspace.xml
27-
.idea/tasks.xml
28-
.idea/watcherTasks.xml
29-
26+
.idea/
3027
test-reports.xml
3128

3229
npm-debug.log
3330
node_modules
34-
resources/App_Resources
35-
resources/Cordova
36-
resources/ItemTemplates
37-
resources/ProjectTemplates

lib/bootstrap.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
global._ = require("underscore");
2-
global.$injector = require("./common/lib/yok").injector;
1+
require("./common/bootstrap");
32

43
$injector.require("nativescript-cli", "./nativescript-cli");
4+
5+
$injector.require("projectService", "./services/project-service");
6+
$injector.require("projectTemplatesService", "./services/project-templates-service");
7+
8+
$injector.requireCommand("create", "./commands/create-project-command");
9+
10+
$injector.require("npm", "./node-package-manager");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="../.d.ts"/>
2+
3+
export class CreateProjectCommand implements ICommand {
4+
constructor(private $projectService: IProjectService) { }
5+
6+
execute(args: string[]): IFuture<void> {
7+
return (() => {
8+
this.$projectService.createProject(args[0], args[1]).wait();
9+
}).future<void>()();
10+
}
11+
}
12+
$injector.registerCommand("create", CreateProjectCommand);

lib/declarations.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface INodePackageManager {
2+
cache: string;
3+
load(config?: any): IFuture<void>;
4+
install(where: string, what: string): IFuture<any>;
5+
}

lib/definitions/npm.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module "npm" {
2+
var cache: string;
3+
var commands: any[];
4+
function load(config: Object, callback: (err: any, data: any) => void);
5+
}

lib/definitions/osenv.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module "osenv" {
2+
function home();
3+
}

lib/definitions/project.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface IProjectService {
2+
createProject(projectName: string, projectId: string): IFuture<void>;
3+
}
4+
5+
interface IProjectTemplatesService {
6+
defaultTemplatePath: IFuture<string>;
7+
}

lib/definitions/shelljs.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module "shelljs" {
2+
function cp(arg: string, sourcePath: string, destinationPath: string): void;
3+
function sed(arg: string, oldValue: any, newValue: string, filePath: string): void;
4+
function mv(source: string[], destination: string);
5+
}

lib/nativescript-cli.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
///<reference path=".d.ts"/>
22

33
import Fiber = require("fibers");
4+
import Future = require("fibers/future");
5+
import path = require("path");
46

57
require("./bootstrap");
8+
require("./options");
69

7-
var fiber = Fiber(() => {
8-
});
9-
global.__main_fiber__ = fiber; // leak fiber to prevent it from being GC'd and thus corrupting V8
10-
fiber.run();
10+
import errors = require("./common/errors");
11+
errors.installUncaughtExceptionListener();
12+
13+
$injector.register("config", {"CI_LOGGER": false});
14+
15+
var dispatcher = $injector.resolve("dispatcher");
16+
dispatcher.runMainFiber();

0 commit comments

Comments
 (0)