Skip to content

Commit e39b49c

Browse files
committed
Merge pull request #6 from NativeScript/fatme/platform-command
Android releated commands - platform add, prepare, build and platform list
2 parents 0646ab3 + c35e02c commit e39b49c

21 files changed

+659
-27
lines changed

lib/bootstrap.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ require("./common/bootstrap");
33
$injector.require("nativescript-cli", "./nativescript-cli");
44

55
$injector.require("projectService", "./services/project-service");
6+
$injector.require("androidProjectService", "./services/project-service");
7+
$injector.require("iOSProjectService", "./services/project-service");
68
$injector.require("projectTemplatesService", "./services/project-templates-service");
9+
$injector.require("platformService", "./services/platform-service");
710

8-
$injector.requireCommand("create", "./commands/create-project-command");
11+
$injector.requireCommand("create", "./commands/create-project");
12+
$injector.requireCommand("platform|*list", "./commands/list-platforms");
13+
$injector.requireCommand("platform|add", "./commands/add-platform");
14+
$injector.requireCommand("run", "./commands/run");
15+
$injector.requireCommand("prepare", "./commands/prepare");
16+
$injector.requireCommand("build", "./commands/build");
917

1018
$injector.require("npm", "./node-package-manager");
19+
$injector.require("propertiesParser", "./properties-parser");

lib/commands/add-platform.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+
3+
export class AddPlatformCommand implements ICommand {
4+
constructor(private $platformService: IPlatformService) { }
5+
6+
execute(args: string[]): IFuture<void> {
7+
return (() => {
8+
this.$platformService.addPlatforms(args).wait();
9+
}).future<void>()();
10+
}
11+
}
12+
$injector.registerCommand("platform|add", AddPlatformCommand);

lib/commands/build.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+
3+
export class BuildCommand implements ICommand {
4+
constructor(private $platformService: IPlatformService) { }
5+
6+
execute(args: string[]): IFuture<void> {
7+
return (() => {
8+
this.$platformService.buildPlatform(args[0]).wait();
9+
}).future<void>()();
10+
}
11+
}
12+
$injector.registerCommand("build", BuildCommand);

lib/commands/list-platforms.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
///<reference path="../.d.ts"/>
2+
import helpers = require("./../common/helpers");
3+
4+
export class ListPlatformsCommand implements ICommand {
5+
constructor(private $platformService: IPlatformService,
6+
private $logger: ILogger) { }
7+
8+
execute(args: string[]): IFuture<void> {
9+
return (() => {
10+
var availablePlatforms = this.$platformService.getAvailablePlatforms().wait();
11+
this.$logger.out("Available platforms: %s", helpers.formatListOfNames(availablePlatforms));
12+
13+
var installedPlatforms = this.$platformService.getInstalledPlatforms().wait();
14+
this.$logger.out("Installed platforms %s", helpers.formatListOfNames(installedPlatforms));
15+
}).future<void>()();
16+
}
17+
}
18+
$injector.registerCommand("platform|*list", ListPlatformsCommand);
19+
20+

lib/commands/prepare.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+
3+
export class PrepareCommand implements ICommand {
4+
constructor(private $platformService: IPlatformService) { }
5+
6+
execute(args: string[]): IFuture<void> {
7+
return (() => {
8+
this.$platformService.preparePlatform(args[0]).wait();
9+
}).future<void>()();
10+
}
11+
}
12+
$injector.registerCommand("prepare", PrepareCommand);

lib/commands/run.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+
3+
export class RunCommand implements ICommand {
4+
constructor(private $platformService: IPlatformService) { }
5+
6+
execute(args: string[]): IFuture<void> {
7+
return (() => {
8+
this.$platformService.runPlatform(args[0]).wait();
9+
}).future<void>()();
10+
}
11+
}
12+
$injector.registerCommand("run", RunCommand);

lib/declarations.ts

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

lib/definitions/platform.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
interface IPlatformService {
2+
addPlatforms(platforms: string[]): IFuture<void>;
3+
getInstalledPlatforms(): IFuture<string[]>;
4+
getAvailablePlatforms(): IFuture<string[]>;
5+
runPlatform(platform: string): IFuture<void>;
6+
preparePlatform(platform: string): IFuture<void>;
7+
buildPlatform(platform: string): IFuture<void>;
8+
}
9+
10+
interface IPlatformCapabilities {
11+
targetedOS?: string[];
12+
}

0 commit comments

Comments
 (0)