-
-
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
Merged
Merged
Kddimitrov/aab build #4084
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1860059
feat: inital work on Android Application Bundle Build (.aab)
KristianDD 58d57fd
chore: unify interfaces
KristianDD dac46b7
feat: add validations for --aab command
KristianDD 61d9843
fix: hashes with --aab outputed in wrong directory
KristianDD 4bb3bdc
feat: validation for runtime version for --aab, linting, tests fix
KristianDD d40fc5a
test: add tests for androidBundle
KristianDD 2cb7013
feat: print output path of .aab file
KristianDD d5432f7
chore: lint and remove only in tests
KristianDD ba7cac4
chore: fix comments
KristianDD 11bd5ba
chore: add help for aab flag
KristianDD a29ced3
chore: fix aab messages after review
KristianDD a6dcfb9
chore: fix comments aab
KristianDD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 && | ||
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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Cool! I really like it. But we can make it even better.
So no need to provide
semver.gte
function as a param to another function.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.
isVersionLowerThan
is actually misleading, because it does not imply forgte
comparison, butgt
comparison. I prefer sending a function to be used to compare the values. This makes the helper much more versatile for future use.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.
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
compareCoerceVersions
it will affect ALL the calls above.So we will wonder "how this will affect the case when the function is called for example with
semver.gt
" or Will it affect the case when passed function issemver.lte
. So it will be harder to read + less control over the affected parts.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.
Even if I create a wrapper for each comparison
semver
has, it will underneath use the same private method that wraps the same logic (getting the coerce of each version and invoking a function). So changing the private method will affect the same amount of places, but indirectly.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.
@rosen-vladimirov @DimitarTachev I would appreciate your input on the matter. If the majority considers it's better to wrap
semver
methods I will do it.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.
I prefer a few but simple functions. Methods like
isVersionLowerThan
are more clear, simple and easy to be unit tested. It's much easier todo one thing and do it well
for such functions. In other words, I prefer sticking to simple functions till we don't need more complex scenario requiring some custom comparisons.