Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 77ec691

Browse files
authored
Merge pull request #138 from NativeScript/kddimitrov/aab-build-validation
feat: add validation for "--aab" build option
2 parents e1de6bb + 469a341 commit 77ec691

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

lib/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $injector.require("nsCloudOptionsProvider", path.join(__dirname, "cloud-options-
99
$injector.require("nsCloudBuildHelper", path.join(__dirname, "cloud-build-helper"));
1010
$injector.require("nsCloudBuildCommandHelper", path.join(__dirname, "commands", "build-command-helper"));
1111
$injector.require("nsCloudEulaCommandHelper", path.join(__dirname, "commands", "eula-command-helper"));
12+
$injector.require("nsCloudAndroidBundleValidatorHelper", path.join(__dirname, "cloud-android-bundle-validator-helper"));
1213
$injector.require("nsCloudKinveyUserService", path.join(__dirname, "services", "kinvey-user-service"));
1314
$injector.require("nsCloudTelerikUserService", path.join(__dirname, "services", "telerik-user-service"));
1415

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export class CloudAndroidBundleValidatorHelper implements IAndroidBundleValidatorHelper {
2+
protected get $bundleValidatorHelper(): IAndroidBundleValidatorHelper {
3+
return this.$nsCloudPolyfillService.getPolyfillObject<IAndroidBundleValidatorHelper>("androidBundleValidatorHelper", {
4+
validateNoAab: () => { /* Mock */ },
5+
validateRuntimeVersion: () => { /* Mock */ }
6+
});
7+
}
8+
9+
constructor(private $nsCloudPolyfillService: IPolyfillService) { }
10+
11+
validateNoAab() {
12+
return this.$bundleValidatorHelper.validateNoAab();
13+
}
14+
15+
validateRuntimeVersion(projectData: IProjectData) {
16+
return this.$bundleValidatorHelper.validateRuntimeVersion(projectData);
17+
}
18+
}
19+
20+
$injector.register("nsCloudAndroidBundleValidatorHelper", CloudAndroidBundleValidatorHelper);

lib/commands/cloud-build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export class CloudBuildCommand extends BundleValidatorBaseCommand implements ICo
1414
private $nsCloudBuildService: ICloudBuildService,
1515
private $nsCloudOptionsProvider: ICloudOptionsProvider,
1616
private $options: ICloudOptions,
17-
private $projectData: IProjectData) {
17+
private $projectData: IProjectData,
18+
private $nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
1819
super($nsCloudPolyfillService);
1920
this.$projectData.initializeProjectData();
2021
}
@@ -31,6 +32,7 @@ export class CloudBuildCommand extends BundleValidatorBaseCommand implements ICo
3132
public async canExecute(args: string[]): Promise<boolean> {
3233
this.$bundleValidatorHelper.validate();
3334
await this.$nsCloudEulaCommandHelper.ensureEulaIsAccepted();
35+
this.$nsCloudAndroidBundleValidatorHelper.validateNoAab();
3436

3537
if (!args || !args.length) {
3638
this.$errors.fail("Provide platform.");

lib/commands/cloud-deploy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export class CloudDeploy extends BundleValidatorBaseCommand implements ICommand
1616
private $nsCloudBuildService: ICloudBuildService,
1717
private $nsCloudOptionsProvider: ICloudOptionsProvider,
1818
private $options: ICloudOptions,
19-
private $projectData: IProjectData) {
19+
private $projectData: IProjectData,
20+
private $nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
2021
super($nsCloudPolyfillService);
2122
this.$projectData.initializeProjectData();
2223
}
@@ -40,6 +41,7 @@ export class CloudDeploy extends BundleValidatorBaseCommand implements ICommand
4041
public async canExecute(args: string[]): Promise<boolean> {
4142
this.$bundleValidatorHelper.validate();
4243
await this.$nsCloudEulaCommandHelper.ensureEulaIsAccepted();
44+
this.$nsCloudAndroidBundleValidatorHelper.validateNoAab();
4345

4446
if (!args || !args.length) {
4547
this.$errors.fail("Provide platform.");

lib/commands/cloud-publish.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ abstract class CloudPublish implements ICommand {
1111
protected $prompter: IPrompter,
1212
protected $projectData: IProjectData,
1313
protected $options: ICloudOptions,
14-
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
14+
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
15+
protected $nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
1516
this.$projectData.initializeProjectData();
1617
}
1718

1819
public abstract execute(args: string[]): Promise<void>;
19-
public abstract canExecute(args: string[]): Promise<boolean>;
20+
21+
public async canExecute(args: string[]): Promise<boolean> {
22+
this.$nsCloudAndroidBundleValidatorHelper.validateNoAab();
23+
24+
return true;
25+
}
2026
}
2127

2228
export class CloudPublishAndroid extends CloudPublish implements ICommand {
@@ -28,8 +34,10 @@ export class CloudPublishAndroid extends CloudPublish implements ICommand {
2834
protected $prompter: IPrompter,
2935
protected $projectData: IProjectData,
3036
protected $options: ICloudOptions,
31-
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
32-
super($nsCloudOptionsProvider, $prompter, $projectData, $options, $devicePlatformsConstants);
37+
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
38+
$nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper
39+
) {
40+
super($nsCloudOptionsProvider, $prompter, $projectData, $options, $devicePlatformsConstants, $nsCloudAndroidBundleValidatorHelper);
3341
}
3442

3543
public async execute(args: string[]): Promise<void> {
@@ -57,6 +65,8 @@ export class CloudPublishAndroid extends CloudPublish implements ICommand {
5765
public async canExecute(args: string[]): Promise<boolean> {
5866
await this.$nsCloudEulaCommandHelper.ensureEulaIsAccepted();
5967

68+
await super.canExecute(args);
69+
6070
if (args.length > 1 || (!isInteractive() && args.length < 1)) {
6171
this.$errors.fail("The command accepts only one parameter - Path to authentication JSON");
6272
}
@@ -76,8 +86,9 @@ export class CloudPublishIos extends CloudPublish implements ICommand {
7686
protected $prompter: IPrompter,
7787
protected $projectData: IProjectData,
7888
protected $options: ICloudOptions,
79-
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
80-
super($nsCloudOptionsProvider, $prompter, $projectData, $options, $devicePlatformsConstants);
89+
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
90+
$nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
91+
super($nsCloudOptionsProvider, $prompter, $projectData, $options, $devicePlatformsConstants, $nsCloudAndroidBundleValidatorHelper);
8192
}
8293

8394
public async execute(args: string[]): Promise<void> {
@@ -96,6 +107,8 @@ export class CloudPublishIos extends CloudPublish implements ICommand {
96107
public async canExecute(args: string[]): Promise<boolean> {
97108
await this.$nsCloudEulaCommandHelper.ensureEulaIsAccepted();
98109

110+
await super.canExecute(args);
111+
99112
if (args.length > 2 || (!isInteractive() && args.length < 1)) {
100113
this.$errors.fail(ERROR_MESSAGES.COMMAND_REQUIRES_APPLE_USERNAME_PASS);
101114
}

lib/commands/cloud-run.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export class CloudRunCommand implements ICommand {
1212
private $nsCloudBuildCommandHelper: IBuildCommandHelper,
1313
private $errors: IErrors,
1414
private $nsCloudOptionsProvider: ICloudOptionsProvider,
15-
private $projectData: IProjectData) {
15+
private $projectData: IProjectData,
16+
private $nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
1617
this.$projectData.initializeProjectData();
1718
}
1819

@@ -26,6 +27,7 @@ export class CloudRunCommand implements ICommand {
2627

2728
public async canExecute(args: string[]): Promise<boolean> {
2829
await this.$nsCloudEulaCommandHelper.ensureEulaIsAccepted();
30+
this.$nsCloudAndroidBundleValidatorHelper.validateNoAab();
2931

3032
if (args.length) {
3133
this.$errors.fail("This input is not valid for the cloud run command");
@@ -51,8 +53,9 @@ export class CloudRunIosCommand extends CloudRunCommand implements ICommand {
5153
$nsCloudOptionsProvider: ICloudOptionsProvider,
5254
$devicesService: Mobile.IDevicesService,
5355
$projectData: IProjectData,
56+
$nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper,
5457
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
55-
super($liveSyncCommandHelper, $nsCloudEulaCommandHelper, $nsCloudBuildService, $nsCloudBuildCommandHelper, $errors, $nsCloudOptionsProvider, $projectData);
58+
super($liveSyncCommandHelper, $nsCloudEulaCommandHelper, $nsCloudBuildService, $nsCloudBuildCommandHelper, $errors, $nsCloudOptionsProvider, $projectData, $nsCloudAndroidBundleValidatorHelper);
5659
}
5760
}
5861

@@ -72,8 +75,9 @@ export class CloudRunAndroidCommand extends CloudRunCommand implements ICommand
7275
$nsCloudOptionsProvider: ICloudOptionsProvider,
7376
$devicesService: Mobile.IDevicesService,
7477
$projectData: IProjectData,
78+
$nsCloudAndroidBundleValidatorHelper: IAndroidBundleValidatorHelper,
7579
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
76-
super($liveSyncCommandHelper, $nsCloudEulaCommandHelper, $nsCloudBuildService, $nsCloudBuildCommandHelper, $errors, $nsCloudOptionsProvider, $projectData);
80+
super($liveSyncCommandHelper, $nsCloudEulaCommandHelper, $nsCloudBuildService, $nsCloudBuildCommandHelper, $errors, $nsCloudOptionsProvider, $projectData, $nsCloudAndroidBundleValidatorHelper);
7781
}
7882
}
7983

0 commit comments

Comments
 (0)