Skip to content

Commit 4ca31f7

Browse files
committed
Warn users that android related command need all --key-store- parameters when using --release
Fixes #839
1 parent 9aebd15 commit 4ca31f7

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

lib/commands/build.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ $injector.registerCommand("build|ios", BuildIosCommand);
2626
export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
2727
constructor($platformService: IPlatformService,
2828
private $platformsData: IPlatformsData,
29-
private $options: IOptions) {
29+
private $options: IOptions,
30+
private $errors: IErrors) {
3031
super($platformService);
3132
}
3233

@@ -36,5 +37,14 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
3637
}
3738

3839
public allowedParameters: ICommandParameter[] = [];
40+
41+
public canExecute(args: string[]): IFuture<boolean> {
42+
return (() => {
43+
if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {
44+
this.$errors.fail("When producing a release build, you need to specify all --key-store-* options.");
45+
}
46+
return args.length === 0;
47+
}).future<boolean>()();
48+
}
3949
}
4050
$injector.registerCommand("build|android", BuildAndroidCommand);

lib/commands/deploy.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@
33

44
export class DeployOnDeviceCommand implements ICommand {
55
constructor(private $platformService: IPlatformService,
6-
private $platformCommandParameter: ICommandParameter) { }
6+
private $platformCommandParameter: ICommandParameter,
7+
private $options: IOptions,
8+
private $errors: IErrors) { }
79

810
execute(args: string[]): IFuture<void> {
911
return this.$platformService.deployOnDevice(args[0]);
1012
}
1113

12-
allowedParameters = [this.$platformCommandParameter];
14+
public canExecute(args: string[]): IFuture<boolean> {
15+
return (() => {
16+
if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {
17+
this.$errors.fail("When producing a release build, you need to specify all --key-store-* options.");
18+
}
19+
let res = (args.length === 1) && this.$platformCommandParameter.validate(args[0]).wait();
20+
return res;
21+
}).future<boolean>()();
22+
}
23+
24+
allowedParameters: ICommandParameter[] = [];
1325
}
1426
$injector.registerCommand("deploy", DeployOnDeviceCommand);

lib/commands/run.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,25 @@ $injector.registerCommand("run|ios", RunIosCommand);
2525

2626
export class RunAndroidCommand extends RunCommandBase implements ICommand {
2727
constructor($platformService: IPlatformService,
28-
private $platformsData: IPlatformsData) {
29-
super($platformService);
28+
private $platformsData: IPlatformsData,
29+
private $options: IOptions,
30+
private $errors: IErrors) {
31+
super($platformService);
3032
}
3133

3234
public allowedParameters: ICommandParameter[] = [];
3335

3436
public execute(args: string[]): IFuture<void> {
3537
return this.executeCore([this.$platformsData.availablePlatforms.Android]);
3638
}
39+
40+
public canExecute(args: string[]): IFuture<boolean> {
41+
return (() => {
42+
if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {
43+
this.$errors.fail("When producing a release build, you need to specify all --key-store-* options.");
44+
}
45+
return args.length === 0;
46+
}).future<boolean>()();
47+
}
3748
}
3849
$injector.registerCommand("run|android", RunAndroidCommand);

0 commit comments

Comments
 (0)