Skip to content

Commit 27f9c09

Browse files
committed
Fix options validation for 'tns prepare', add validation for 'tns livesync', fix .name to .uuid in provision checks
1 parent 982c7b6 commit 27f9c09

File tree

10 files changed

+63
-20
lines changed

10 files changed

+63
-20
lines changed

lib/commands/build.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
3030
}
3131

3232
public canExecute(args: string[]): IFuture<boolean> {
33-
return this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS);
33+
return (() => {
34+
return args.length === 0 && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
35+
}).future<boolean>()();
3436
}
3537
}
3638
$injector.registerCommand("build|ios", BuildIosCommand);

lib/commands/debug.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
88
private $config: IConfiguration,
99
private $usbLiveSyncService: ILiveSyncService,
10-
private $platformService: IPlatformService,
11-
protected $options: IOptions) { }
10+
protected $platformService: IPlatformService,
11+
protected $options: IOptions,
12+
protected $platformsData: IPlatformsData) { }
1213

1314
execute(args: string[]): IFuture<void> {
1415
if (this.$options.start) {
@@ -67,8 +68,16 @@ export class DebugIOSCommand extends DebugPlatformCommand {
6768
$config: IConfiguration,
6869
$usbLiveSyncService: ILiveSyncService,
6970
$platformService: IPlatformService,
70-
$options: IOptions) {
71-
super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options);
71+
$options: IOptions,
72+
$platformsData: IPlatformsData) {
73+
74+
super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options, $platformsData);
75+
}
76+
77+
canExecute(args: string[]): IFuture<boolean> {
78+
return (() => {
79+
return super.canExecute(args).wait() && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
80+
}).future<boolean>()();
7281
}
7382
}
7483
$injector.registerCommand("debug|ios", DebugIOSCommand);
@@ -83,8 +92,16 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
8392
$config: IConfiguration,
8493
$usbLiveSyncService: ILiveSyncService,
8594
$platformService: IPlatformService,
86-
$options: IOptions) {
87-
super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options);
95+
$options: IOptions,
96+
$platformsData: IPlatformsData) {
97+
98+
super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options, $platformsData);
99+
}
100+
101+
canExecute(args: string[]): IFuture<boolean> {
102+
return (() => {
103+
return super.canExecute(args).wait() && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.Android).wait();
104+
}).future<boolean>()();
88105
}
89106
}
90107
$injector.registerCommand("debug|android", DebugAndroidCommand);

lib/commands/livesync.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ export class LivesyncCommand implements ICommand {
1313

1414
public canExecute(args: string[]): IFuture<boolean> {
1515
return (() => {
16-
if(args.length >= 2) {
16+
if (args.length >= 2) {
1717
this.$errors.fail("Invalid number of arguments.");
1818
}
1919

2020
let platform = args[0];
21-
if(platform) {
22-
return _.includes(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform));
21+
if (platform) {
22+
return _.includes(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform)) && this.$platformService.validateOptions(args[0]).wait();
23+
} else {
24+
return this.$platformService.validateOptions().wait();
2325
}
24-
25-
return true;
2626
}).future<boolean>()();
2727
}
2828

lib/commands/prepare.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class PrepareCommand implements ICommand {
1010
}
1111

1212
public canExecute(args: string[]): IFuture<boolean> {
13-
return this.$platformService.validateOptions(args[0]);
13+
return (() => {
14+
return this.$platformCommandParameter.validate(args[0]).wait() && this.$platformService.validateOptions(args[0]).wait();
15+
}).future<boolean>()();
1416
}
1517

1618
allowedParameters = [this.$platformCommandParameter];

lib/commands/run.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
2828
}
2929

3030
public canExecute(args: string[]): IFuture<boolean> {
31-
return this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS);
31+
return (() => {
32+
return args.length === 0 && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
33+
}).future<boolean>()();
3234
}
3335
}
3436
$injector.registerCommand("run|ios", RunIosCommand);

lib/definitions/platform.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ interface IPlatformService {
7878

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

8486
/**
8587
* Executes prepare, build and installOnPlatform when necessary to ensure that the latest version of the app is installed on specified platform.

lib/services/ios-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
348348
if (signing && signing.style === "Manual") {
349349
for(let config in signing.configurations) {
350350
let options = signing.configurations[config];
351-
if (options.name !== this.$options.provision && options.name !== this.$options.provision) {
351+
if (options.name !== this.$options.provision && options.uuid !== this.$options.provision) {
352352
shouldUpdateXcode = true;
353353
break;
354354
}

lib/services/platform-service.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,22 @@ export class PlatformService implements IPlatformService {
227227
}).future<boolean>()();
228228
}
229229

230-
public validateOptions(platform: string): IFuture<boolean> {
230+
public validateOptions(platform?: string): IFuture<boolean> {
231231
return (() => {
232-
let platformData = this.$platformsData.getPlatformData(platform);
233-
return platformData.platformProjectService.validateOptions().wait();
232+
if (platform) {
233+
platform = this.$mobileHelper.normalizePlatformName(platform);
234+
this.$logger.trace("Validate options for platform: " + platform);
235+
let platformData = this.$platformsData.getPlatformData(platform);
236+
return platformData.platformProjectService.validateOptions().wait();
237+
} else {
238+
let valid = true;
239+
for (let availablePlatform in this.$platformsData.availablePlatforms) {
240+
this.$logger.trace("Validate options for platform: " + availablePlatform);
241+
let platformData = this.$platformsData.getPlatformData(availablePlatform);
242+
valid = valid && platformData.platformProjectService.validateOptions().wait();
243+
}
244+
return valid;
245+
}
234246
}).future<boolean>()();
235247
}
236248

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"mute-stream": "0.0.5",
5959
"open": "0.0.5",
6060
"osenv": "0.1.3",
61-
"pbxproj-dom": "^1.0.7",
61+
"pbxproj-dom": "1.0.7",
6262
"plist": "1.1.0",
6363
"plist-merge-patch": "0.0.9",
6464
"plistlib": "0.2.1",

test/debug.ts

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ function createTestInjector(): IInjector {
4848
testInjector.register("adb", AndroidDebugBridge);
4949
testInjector.register("androidDebugBridgeResultHandler", AndroidDebugBridgeResultHandler);
5050
testInjector.register("platformService", stubs.PlatformServiceStub);
51+
testInjector.register("platformsData", {
52+
availablePlatforms: {
53+
Android: "Android",
54+
iOS: "iOS"
55+
}
56+
});
5157

5258
return testInjector;
5359
}

0 commit comments

Comments
 (0)