Skip to content
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
4 changes: 3 additions & 1 deletion lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
}

public canExecute(args: string[]): IFuture<boolean> {
return this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS);
return (() => {
return args.length === 0 && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
}).future<boolean>()();
}
}
$injector.registerCommand("build|ios", BuildIosCommand);
Expand Down
29 changes: 23 additions & 6 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $config: IConfiguration,
private $usbLiveSyncService: ILiveSyncService,
private $platformService: IPlatformService,
protected $options: IOptions) { }
protected $platformService: IPlatformService,
protected $options: IOptions,
protected $platformsData: IPlatformsData) { }

execute(args: string[]): IFuture<void> {
if (this.$options.start) {
Expand Down Expand Up @@ -67,8 +68,16 @@ export class DebugIOSCommand extends DebugPlatformCommand {
$config: IConfiguration,
$usbLiveSyncService: ILiveSyncService,
$platformService: IPlatformService,
$options: IOptions) {
super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options);
$options: IOptions,
$platformsData: IPlatformsData) {

super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options, $platformsData);
}

canExecute(args: string[]): IFuture<boolean> {
return (() => {
return super.canExecute(args).wait() && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
}).future<boolean>()();
}
}
$injector.registerCommand("debug|ios", DebugIOSCommand);
Expand All @@ -83,8 +92,16 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
$config: IConfiguration,
$usbLiveSyncService: ILiveSyncService,
$platformService: IPlatformService,
$options: IOptions) {
super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options);
$options: IOptions,
$platformsData: IPlatformsData) {

super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options, $platformsData);
}

canExecute(args: string[]): IFuture<boolean> {
return (() => {
return super.canExecute(args).wait() && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.Android).wait();
}).future<boolean>()();
}
}
$injector.registerCommand("debug|android", DebugAndroidCommand);
10 changes: 5 additions & 5 deletions lib/commands/livesync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export class LivesyncCommand implements ICommand {

public canExecute(args: string[]): IFuture<boolean> {
return (() => {
if(args.length >= 2) {
if (args.length >= 2) {
this.$errors.fail("Invalid number of arguments.");
}

let platform = args[0];
if(platform) {
return _.includes(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform));
if (platform) {
return _.includes(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform)) && this.$platformService.validateOptions(args[0]).wait();
} else {
return this.$platformService.validateOptions().wait();
}

return true;
}).future<boolean>()();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export class PrepareCommand implements ICommand {
}

public canExecute(args: string[]): IFuture<boolean> {
return this.$platformService.validateOptions(args[0]);
return (() => {
return this.$platformCommandParameter.validate(args[0]).wait() && this.$platformService.validateOptions(args[0]).wait();
}).future<boolean>()();
}

allowedParameters = [this.$platformCommandParameter];
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
}

public canExecute(args: string[]): IFuture<boolean> {
return this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS);
return (() => {
return args.length === 0 && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
}).future<boolean>()();
}
}
$injector.registerCommand("run|ios", RunIosCommand);
Expand Down
4 changes: 3 additions & 1 deletion lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ interface IPlatformService {

/**
* Gets first chance to validate the options provided as command line arguments.
* If no platform is provided or a falsy (null, undefined, "", false...) platform is provided,
* the options will be validated for all available platforms.
*/
validateOptions(platform: string): IFuture<boolean>;
validateOptions(platform?: string): IFuture<boolean>;

/**
* Executes prepare, build and installOnPlatform when necessary to ensure that the latest version of the app is installed on specified platform.
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
if (signing && signing.style === "Manual") {
for(let config in signing.configurations) {
let options = signing.configurations[config];
if (options.name !== this.$options.provision && options.name !== this.$options.provision) {
if (options.name !== this.$options.provision && options.uuid !== this.$options.provision) {
shouldUpdateXcode = true;
break;
}
Expand Down
18 changes: 15 additions & 3 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,22 @@ export class PlatformService implements IPlatformService {
}).future<boolean>()();
}

public validateOptions(platform: string): IFuture<boolean> {
public validateOptions(platform?: string): IFuture<boolean> {
return (() => {
let platformData = this.$platformsData.getPlatformData(platform);
return platformData.platformProjectService.validateOptions().wait();
if (platform) {
platform = this.$mobileHelper.normalizePlatformName(platform);
this.$logger.trace("Validate options for platform: " + platform);
let platformData = this.$platformsData.getPlatformData(platform);
return platformData.platformProjectService.validateOptions().wait();
} else {
let valid = true;
for (let availablePlatform in this.$platformsData.availablePlatforms) {
this.$logger.trace("Validate options for platform: " + availablePlatform);
let platformData = this.$platformsData.getPlatformData(availablePlatform);
valid = valid && platformData.platformProjectService.validateOptions().wait();
}
return valid;
}
}).future<boolean>()();
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"mute-stream": "0.0.5",
"open": "0.0.5",
"osenv": "0.1.3",
"pbxproj-dom": "^1.0.7",
"pbxproj-dom": "1.0.7",
"plist": "1.1.0",
"plist-merge-patch": "0.0.9",
"plistlib": "0.2.1",
Expand Down
6 changes: 6 additions & 0 deletions test/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ function createTestInjector(): IInjector {
testInjector.register("adb", AndroidDebugBridge);
testInjector.register("androidDebugBridgeResultHandler", AndroidDebugBridgeResultHandler);
testInjector.register("platformService", stubs.PlatformServiceStub);
testInjector.register("platformsData", {
availablePlatforms: {
Android: "Android",
iOS: "iOS"
}
});

return testInjector;
}
Expand Down