Skip to content

Remove platform command #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $injector.require("platformService", "./services/platform-service");
$injector.requireCommand("create", "./commands/create-project");
$injector.requireCommand("platform|*list", "./commands/list-platforms");
$injector.requireCommand("platform|add", "./commands/add-platform");
$injector.requireCommand("platform|remove", "./commands/remove-platform");
$injector.requireCommand("run", "./commands/run");
$injector.requireCommand("prepare", "./commands/prepare");
$injector.requireCommand("build", "./commands/build");
Expand Down
12 changes: 12 additions & 0 deletions lib/commands/remove-platform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
///<reference path="../.d.ts"/>

export class RemovePlatformCommand implements ICommand {
constructor(private $platformService: IPlatformService) { }

execute(args: string[]): IFuture<void> {
return (() => {
this.$platformService.removePlatforms(args).wait();
}).future<void>()();
}
}
$injector.registerCommand("platform|remove", RemovePlatformCommand);
1 change: 1 addition & 0 deletions lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface IPlatformService {
runPlatform(platform: string): IFuture<void>;
preparePlatform(platform: string): IFuture<void>;
buildPlatform(platform: string): IFuture<void>;
removePlatforms(platforms: string[]): IFuture<void>;
}

interface IPlatformData {
Expand Down
16 changes: 16 additions & 0 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ export class PlatformService implements IPlatformService {
}).future<void>()();
}

public removePlatforms(platforms: string[]): IFuture<void> {
return (() => {
if(!platforms || platforms.length === 0) {
this.$errors.fail("No platform specified. Please specify a platform to remove");
}

_.each(platforms, platform => {
this.validatePlatformInstalled(platform);

var platformDir = path.join(this.$projectData.platformsDir, platform);
this.$fs.deleteDirectory(platformDir).wait();
});

}).future<void>()();
}

private validatePlatform(platform: string): void {
if (!this.isValidPlatform(platform)) {
this.$errors.fail("Invalid platform %s. Valid platforms are %s.", platform, helpers.formatListOfNames(this.$platformsData.platformsNames));
Expand Down
15 changes: 15 additions & 0 deletions resources/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ General commands:
create Creates a new NativeScript project with given project name and application identifier.
platform add Creates a new platform specific project.
platform list Lists all available and all installed platforms.
platform remove Removes the platform specific project.
prepare Copies files for specified platform, so that the project is ready to build in platform specific SDK.
build Builds the project for the selected target platform and produces an application package.
run This is shorthand for prepare and build.
Expand Down Expand Up @@ -81,6 +82,20 @@ Platform-specific usage:

Creates a new platform specific project. In this version of Telerik NativeScript you can create only ios and android projects.
You can create Android projects on windows and Mac machine. You can create ios projects only on Mac machine.

--[/]--

--[platform|remove]--

Usage:
$ tns platform remove <platform>

Platform-specific usage:
$ tns platform remove android
$ tns platform remove ios

Removes the platform specific project.

--[/]--

--[prepare]--
Expand Down