-
-
Notifications
You must be signed in to change notification settings - Fork 196
Add validation for command parameters #142
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
///<reference path="../.d.ts"/> | ||
"use strict"; | ||
|
||
export class AddPlatformCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
private $errors: IErrors) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return (() => { | ||
this.$platformService.addPlatforms(args).wait(); | ||
}).future<void>()(); | ||
} | ||
|
||
allowedParameters: ICommandParameter[] = []; | ||
|
||
canExecute(args: string[]): IFuture<boolean> { | ||
return (() => { | ||
if(!args || args.length === 0) { | ||
this.$errors.fail("No platform specified. Please specify a platform to add"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if we list available platforms |
||
} | ||
|
||
_.each(args, arg => this.$platformService.validatePlatform(arg)); | ||
|
||
return true; | ||
}).future<boolean>()(); | ||
} | ||
} | ||
$injector.registerCommand("platform|add", AddPlatformCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
///<reference path="../.d.ts"/> | ||
"use strict"; | ||
|
||
export class BuildCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private $platformCommandParameter: ICommandParameter) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return (() => { | ||
this.$platformService.buildPlatform(args[0]).wait(); | ||
}).future<void>()(); | ||
} | ||
|
||
allowedParameters = [this.$platformCommandParameter]; | ||
} | ||
$injector.registerCommand("build", BuildCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
///<reference path="../.d.ts"/> | ||
"use strict"; | ||
|
||
export class DeployOnDeviceCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private $platformCommandParameter: ICommandParameter) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return this.$platformService.deployOnDevice(args[0]); | ||
} | ||
|
||
allowedParameters = [this.$platformCommandParameter]; | ||
} | ||
$injector.registerCommand("deploy", DeployOnDeviceCommand); | ||
$injector.registerCommand("deploy", DeployOnDeviceCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
///<reference path="../.d.ts"/> | ||
|
||
export class EmulateCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
private $platformCommandParameter: ICommandParameter) { } | ||
|
||
execute(args: string[]): IFuture<void> { return this.$platformService.deployOnEmulator(args[0]);} | ||
execute(args: string[]): IFuture<void> { return this.$platformService.deployOnEmulator(args[0]); } | ||
|
||
allowedParameters = [this.$platformCommandParameter]; | ||
} | ||
$injector.registerCommand("emulate", EmulateCommand); | ||
$injector.registerCommand("emulate", EmulateCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
///<reference path="../.d.ts"/> | ||
|
||
export class PrepareCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
private $platformCommandParameter: ICommandParameter) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return (() => { | ||
this.$platformService.preparePlatform(args[0]).wait(); | ||
}).future<void>()(); | ||
} | ||
|
||
allowedParameters = [this.$platformCommandParameter]; | ||
} | ||
$injector.registerCommand("prepare", PrepareCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
///<reference path="../.d.ts"/> | ||
"use strict"; | ||
|
||
export class RemovePlatformCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private $errors: IErrors) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return (() => { | ||
this.$platformService.removePlatforms(args).wait(); | ||
}).future<void>()(); | ||
} | ||
|
||
canExecute(args: string[]): IFuture<boolean> { | ||
return (() => { | ||
if(!args || args.length === 0) { | ||
this.$errors.fail("No platform specified. Please specify a platform to remove"); | ||
} | ||
|
||
_.each(args, arg => this.$platformService.validatePlatformInstalled(arg)); | ||
|
||
return true; | ||
}).future<boolean>()(); | ||
} | ||
|
||
allowedParameters: ICommandParameter[] = []; | ||
} | ||
$injector.registerCommand("platform|remove", RemovePlatformCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
///<reference path="../.d.ts"/> | ||
"use strict"; | ||
|
||
export class RunCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private $platformCommandParameter: ICommandParameter) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return (() => { | ||
this.$platformService.runPlatform(args[0]).wait(); | ||
}).future<void>()(); | ||
} | ||
|
||
allowedParameters = [this.$platformCommandParameter]; | ||
} | ||
$injector.registerCommand("run", RunCommand); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
///<reference path="../.d.ts"/> | ||
"use strict"; | ||
|
||
export class UpdatePlatformCommand implements ICommand { | ||
constructor(private $platformService: IPlatformService) { } | ||
constructor(private $platformService: IPlatformService, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private $errors:IErrors) { } | ||
|
||
execute(args: string[]): IFuture<void> { | ||
return (() => { | ||
this.$platformService.updatePlatforms(args).wait(); | ||
}).future<void>()(); | ||
} | ||
|
||
canExecute(args: string[]): IFuture<boolean> { | ||
return (() => { | ||
if(!args || args.length === 0) { | ||
this.$errors.fail("No platform specified. Please specify platforms to update."); | ||
} | ||
|
||
_.each(args, arg => this.$platformService.validatePlatformInstalled(arg)); | ||
|
||
return true; | ||
}).future<boolean>()(); | ||
} | ||
|
||
allowedParameters: ICommandParameter[] = []; | ||
} | ||
$injector.registerCommand("platform|update", UpdatePlatformCommand); |
+3 −1 | bootstrap.ts | |
+21 −0 | command-params.ts | |
+53 −0 | commands/analytics.ts | |
+2 −0 | commands/help.ts | |
+10 −0 | declarations.d.ts | |
+14 −1 | definitions/commands.d.ts | |
+1 −0 | definitions/yok.d.ts | |
+1 −1 | dispatchers.ts | |
+5 −14 | helpers.ts | |
+1 −1 | http-client.ts | |
+18 −16 | mobile/android/android-emulator-services.ts | |
+1 −1 | options.ts | |
+16 −19 | services/analytics-service.ts | |
+119 −21 | services/commands-service.ts | |
+64 −28 | yok.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
///<reference path=".d.ts"/> | ||
"use strict"; | ||
|
||
export class PlatformCommandParameter implements ICommandParameter { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
constructor(private $platformService: IPlatformService) { } | ||
mandatory = true; | ||
validate(value: string): IFuture<boolean> { | ||
return (() => { | ||
this.$platformService.validatePlatformInstalled(value); | ||
return true; | ||
}).future<boolean>()(); | ||
} | ||
} | ||
$injector.register("platformCommandParameter", PlatformCommandParameter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the file is changed in this PR, we can add the missing
"use strict"