-
-
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 8 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 |
---|---|---|
|
@@ -33,12 +33,14 @@ export const BUILD_XCCONFIG_FILE_NAME = "build.xcconfig"; | |
export const BUILD_DIR = "build"; | ||
export const OUTPUTS_DIR = "outputs"; | ||
export const APK_DIR = "apk"; | ||
export const BUNDLE_DIR = "bundle"; | ||
export const RESOURCES_DIR = "res"; | ||
export const CONFIG_NS_FILE_NAME = "nsconfig.json"; | ||
export const CONFIG_NS_APP_RESOURCES_ENTRY = "appResourcesPath"; | ||
export const CONFIG_NS_APP_ENTRY = "appPath"; | ||
export const DEPENDENCIES_JSON_NAME = "dependencies.json"; | ||
export const APK_EXTENSION_NAME = ".apk"; | ||
export const AAB_EXTENSION_NAME = ".aab"; | ||
export const HASHES_FILE_NAME = ".nshashes"; | ||
|
||
export class PackageVersion { | ||
|
@@ -241,3 +243,8 @@ export class BundleValidatorMessages { | |
public static MissingBundlePlugin = "Passing --bundle requires a bundling plugin. No bundling plugin found or the specified bundling plugin is invalid."; | ||
public static NotSupportedVersion = `The NativeScript CLI requires nativescript-dev-webpack %s or later to work properly. After updating nativescript-dev-webpack you need to ensure "webpack.config.js" file is up to date with the one in the new version of nativescript-dev-webpack. You can automatically update it using "./node_modules/.bin/update-ns-webpack --configs" command.`; | ||
} | ||
|
||
export class AndroidBundleValidatorMessages { | ||
public static AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE = "This command does not support --aab (Android Application Bundle) parameter."; | ||
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. I think AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE is better at describing the message. If you see in constants NOT_SUPPORTED_AAB_OPTION and decide to use it in a service the error message will look strange for sidekick for example. |
||
public static RUNTIME_VERSION_TOO_LOW = "Android Application Bundle (--aab) option requires NativeScript Android Runtime (tns-android) version %s and above."; | ||
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.
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,7 +458,11 @@ interface IPluginSeedOptions { | |
pluginName: string; | ||
} | ||
|
||
interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvailableDevices, IProfileDir, IHasEmulatorOption, IBundleString, IPlatformTemplate, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions, IPluginSeedOptions, IGenerateOptions { | ||
interface IAndroidBundleOptions { | ||
aab: boolean; | ||
} | ||
|
||
interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvailableDevices, IProfileDir, IHasEmulatorOption, IBundleString, IPlatformTemplate, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, IAndroidBundleOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions, IPluginSeedOptions, IGenerateOptions { | ||
argv: IYargArgv; | ||
validateOptions(commandSpecificDashedOptions?: IDictionary<IDashedOption>): void; | ||
options: IDictionary<IDashedOption>; | ||
|
@@ -531,7 +535,11 @@ interface IEnvOptions { | |
env: Object; | ||
} | ||
|
||
interface IAndroidBuildOptionsSettings extends IAndroidReleaseOptions, IRelease { } | ||
interface IAndroidBuildOptionsSettings extends IAndroidReleaseOptions, IRelease, IAndroidBundle { } | ||
|
||
interface IAndroidBundle { | ||
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. IAndroidBundle -> IHasAndroidBundle |
||
androidBundle?: boolean; | ||
} | ||
|
||
interface IAppFilesUpdaterOptions extends IBundle, IRelease, IOptionalWatchAllFiles, IHasUseHotModuleReloadOption { } | ||
|
||
|
@@ -856,6 +864,23 @@ interface IBundleValidatorHelper { | |
validate(minSupportedVersion?: string): void; | ||
} | ||
|
||
|
||
interface IAndroidBundleValidatorHelper { | ||
/** | ||
* Validates android bundling option is not provided. | ||
* Commands that require deploy of the application must not be called with --aab option | ||
* @return {void} | ||
*/ | ||
validateNoAab(): void; | ||
|
||
/** | ||
* Validates android runtime version is sufficient to support bundling option --aab. | ||
* @param {IProjectData} projectData DTO with information about the project. | ||
* @return {void} | ||
*/ | ||
validateRuntimeVersion(projectData: IProjectData): void | ||
} | ||
|
||
interface INativeScriptCloudExtensionService { | ||
/** | ||
* Installs nativescript-cloud extension | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as semver from "semver"; | ||
import * as util from "util"; | ||
import { AndroidBundleValidatorMessages, TNS_ANDROID_RUNTIME_NAME } from "../constants"; | ||
|
||
export class AndroidBundleValidatorHelper implements IAndroidBundleValidatorHelper { | ||
public static MIN_RUNTIME_VERSION = "5.0.0"; | ||
|
||
constructor(protected $projectData: IProjectData, | ||
protected $errors: IErrors, | ||
protected $options: IOptions, | ||
protected $projectDataService: IProjectDataService) { | ||
} | ||
|
||
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) { | ||
const shouldSkipCheck = !semver.valid(androidRuntimeVersion) && !semver.validRange(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. This code is duplicated with the code in
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 have considered a similar approach, but it seemed strange to extract a method with such specific use case. By specific use case I mean - behavior if the version is not valid(someone might want to error in this case) and If you insist I will extract it in separate class and extend the others, but I don't think anyone will ever use it elsewhere. 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. Might extract |
||
if (!shouldSkipCheck) { | ||
const isAndroidBundleSupported = semver.gte(semver.coerce(androidRuntimeVersion), semver.coerce(AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION)); | ||
if (!isAndroidBundleSupported) { | ||
this.$errors.failWithoutHelp(util.format(AndroidBundleValidatorMessages.RUNTIME_VERSION_TOO_LOW, 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.
We could also print the apk output