-
-
Notifications
You must be signed in to change notification settings - Fork 197
Kddimitrov/aab build #4084
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
Kddimitrov/aab build #4084
Changes from 10 commits
1860059
58d57fd
dac46b7
61d9843
4bb3bdc
d40fc5a
2cb7013
d5432f7
ba7cac4
11bd5ba
a29ced3
a6dcfb9
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,4 +1,4 @@ | ||
import { ANDROID_RELEASE_BUILD_ERROR_MESSAGE } from "../constants"; | ||
import { ANDROID_RELEASE_BUILD_ERROR_MESSAGE, AndroidAppBundleMessages } from "../constants"; | ||
import { ValidatePlatformCommandBase } from "./command-base"; | ||
|
||
export abstract class BuildCommandBase extends ValidatePlatformCommandBase { | ||
|
@@ -8,12 +8,13 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase { | |
$platformsData: IPlatformsData, | ||
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, | ||
$platformService: IPlatformService, | ||
private $bundleValidatorHelper: IBundleValidatorHelper) { | ||
private $bundleValidatorHelper: IBundleValidatorHelper, | ||
protected $logger: ILogger) { | ||
super($options, $platformsData, $platformService, $projectData); | ||
this.$projectData.initializeProjectData(); | ||
} | ||
|
||
public async executeCore(args: string[]): Promise<void> { | ||
public async executeCore(args: string[]): Promise<string> { | ||
const platform = args[0].toLowerCase(); | ||
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { | ||
bundle: !!this.$options.bundle, | ||
|
@@ -41,12 +42,19 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase { | |
keyStoreAlias: this.$options.keyStoreAlias, | ||
keyStorePath: this.$options.keyStorePath, | ||
keyStoreAliasPassword: this.$options.keyStoreAliasPassword, | ||
keyStorePassword: this.$options.keyStorePassword | ||
keyStorePassword: this.$options.keyStorePassword, | ||
androidBundle: this.$options.aab | ||
}; | ||
await this.$platformService.buildPlatform(platform, buildConfig, this.$projectData); | ||
|
||
const outputPath = await this.$platformService.buildPlatform(platform, buildConfig, this.$projectData); | ||
|
||
if (this.$options.copyTo) { | ||
this.$platformService.copyLastOutput(platform, this.$options.copyTo, buildConfig, this.$projectData); | ||
} else { | ||
this.$logger.info(`Your build result is located at: ${outputPath}`); | ||
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. I am not very familiar with the CLI errors, but if you/your is not used a lot, I would recommend changing this to "The build result is located at" instead of "Your..." |
||
} | ||
|
||
return outputPath; | ||
} | ||
|
||
protected validatePlatform(platform: string): void { | ||
|
@@ -84,12 +92,13 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand { | |
$platformsData: IPlatformsData, | ||
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants, | ||
$platformService: IPlatformService, | ||
$bundleValidatorHelper: IBundleValidatorHelper) { | ||
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper); | ||
$bundleValidatorHelper: IBundleValidatorHelper, | ||
$logger: ILogger) { | ||
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper, $logger); | ||
} | ||
|
||
public async execute(args: string[]): Promise<void> { | ||
return this.executeCore([this.$platformsData.availablePlatforms.iOS]); | ||
await this.executeCore([this.$platformsData.availablePlatforms.iOS]); | ||
} | ||
|
||
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> { | ||
|
@@ -117,18 +126,28 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand { | |
$platformsData: IPlatformsData, | ||
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants, | ||
$platformService: IPlatformService, | ||
$bundleValidatorHelper: IBundleValidatorHelper) { | ||
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper); | ||
$bundleValidatorHelper: IBundleValidatorHelper, | ||
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper, | ||
protected $logger: ILogger) { | ||
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper, $logger); | ||
} | ||
|
||
public async execute(args: string[]): Promise<void> { | ||
return this.executeCore([this.$platformsData.availablePlatforms.Android]); | ||
await this.executeCore([this.$platformsData.availablePlatforms.Android]); | ||
|
||
if (this.$options.aab) { | ||
this.$logger.info(AndroidAppBundleMessages.ANDROID_APP_BUNDLE_DOCS_MESSAGE); | ||
|
||
if (this.$options.release) { | ||
this.$logger.info(AndroidAppBundleMessages.ANDROID_APP_BUNDLE_PUBLISH_DOCS_MESSAGE); | ||
} | ||
} | ||
} | ||
|
||
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> { | ||
const platform = this.$devicePlatformsConstants.Android; | ||
super.validatePlatform(platform); | ||
|
||
this.$androidBundleValidatorHelper.validateRuntimeVersion(this.$projectData); | ||
let result = await super.canExecuteCommandBase(platform, { notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true }}); | ||
if (result.canExecute) { | ||
if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as semver from "semver"; | ||
import * as util from "util"; | ||
import { AndroidBundleValidatorMessages, TNS_ANDROID_RUNTIME_NAME } from "../constants"; | ||
import { VersionValidatorHelper } from "./version-validator-helper"; | ||
|
||
export class AndroidBundleValidatorHelper extends VersionValidatorHelper implements IAndroidBundleValidatorHelper { | ||
public static MIN_RUNTIME_VERSION = "5.0.0"; | ||
|
||
constructor(protected $projectData: IProjectData, | ||
protected $errors: IErrors, | ||
protected $options: IOptions, | ||
protected $projectDataService: IProjectDataService) { | ||
super(); | ||
} | ||
|
||
public validateNoAab(): void { | ||
if (this.$options.aab) { | ||
this.$errors.fail(AndroidBundleValidatorMessages.AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE); | ||
} | ||
} | ||
|
||
public validateRuntimeVersion(projectData: IProjectData): void { | ||
if (this.$options.aab) { | ||
const androidRuntimeInfo = this.$projectDataService.getNSValue(projectData.projectDir, TNS_ANDROID_RUNTIME_NAME); | ||
const androidRuntimeVersion = androidRuntimeInfo ? androidRuntimeInfo.version : ""; | ||
|
||
if (androidRuntimeVersion && | ||
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. Cool! I really like it. But we can make it even better.
So no need to provide 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.
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.
If we decide to change the implementation or add additional logic to some of the above functions, the change will affect ONLY the specific function. So we will have simplification + more control over the affected parts.
If we decide to change the implementation of 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. Even if I create a wrapper for each comparison 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. @rosen-vladimirov @DimitarTachev I would appreciate your input on the matter. If the majority considers it's better to wrap 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. I prefer a few but simple functions. Methods like |
||
this.isValidVersion(androidRuntimeVersion) && | ||
!this.compareCoerceVersions(androidRuntimeVersion, AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION, semver.gte)) { | ||
this.$errors.failWithoutHelp(util.format(AndroidBundleValidatorMessages.NOT_SUPPORTED_RUNTIME_VERSION, AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$injector.register("androidBundleValidatorHelper", AndroidBundleValidatorHelper); |
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.
You should consider replacing "must" with "will". It sounds better to say what the command will do :)