Skip to content
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

[FIX] generateFlexChangesBundle: Fix minUI5Version check for UI5 v1.100.0+ #706

Merged
merged 8 commits into from
Feb 21, 2022

Conversation

thuyboehm
Copy link
Contributor

The minUI5Version check is needed for generate a flexibility-bundle or a change-bundle. The check is now separated for the major and minor version number.

@coveralls
Copy link

coveralls commented Feb 21, 2022

Coverage Status

Coverage decreased (-0.01%) to 94.755% when pulling d9c8f95 on thuyboehm:versionFix into 170c90b on SAP:master.

let hasFlexBundleVersion = false;
if (parseFloat(version) >= 1.73) {
if (versionArray.length >= 2 && parseFloat(versionArray[0]) >= 1 && parseFloat(versionArray[1]) >= 73) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the semver package to compare versions. It's already a dependency of this project, so you just need to require it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use semver

let hasFlexBundleVersion = false;
if (versionArray.length >= 2 && parseFloat(versionArray[0]) >= 1 && parseFloat(versionArray[1]) >= 73) {
if (version.major >= MIN_UI5_VERION_1_73.major && version.minor >= MIN_UI5_VERION_1_73.minor) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could compare method be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already use

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I viewed an old version

matz3
matz3 previously approved these changes Feb 21, 2022
@matz3 matz3 changed the title [INTERNAL][FIX] check of minUI5Version as version number [FIX] generateFlexChangesBundle: Fix minUI5Version check for UI5 v1.100.0+ Feb 21, 2022
@matz3
Copy link
Member

matz3 commented Feb 21, 2022

@thuyboehm could you please sign the CLA via https://cla-assistant.io/SAP/ui5-builder?pullRequest=706 ?
It seems that the automatic comment hasn't been posted, and the check is currently pending.

let hasFlexBundleVersion = false;
if (parseFloat(version) >= 1.73) {
if (version.compare(MIN_UI5_VERION_1_73) >= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my two cents: This is a pretty odd way of using the semver API, that I haven't seen so far and also couldn't find in the documentation at https://github.com/npm/node-semver#readme

IMHO semver.compare(version, "1.73.0") >= 0 would be sufficient and does not involve the creation of Version instances.

But I guess your solution works too and since it's your code we are totally fine with merging this as is. Please let us know soon in case you want to change this. Otherwise we will proceed with releasing this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: I meant semver.compare, not version.compare

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just change it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it necessary to semver.coerce the version from the manifest first? I recently worked with semver for the first time and was puzzled that it doesn't do this automatically, at least not with the convenience comparison methods (semver.lt etc.).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. As the manifest.json schema doesn't validate the "minUI5Version" properly (just type "string"), it is likely that the patch version is missing in some cases (e.g. 1.100). This should also be covered in the tests.

Copy link
Member

@matz3 matz3 Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, even our manifestCreator just uses major.minor without the patch version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...which totally makes sense to me as the patch version doesn't play a role wrt. APIs. It's just that semver doesn't handle such short versions with a call to semver.coerce.

@matz3
Copy link
Member

matz3 commented Feb 21, 2022

Maybe some test cases for the "major.minor" version would be good to have, right?

@thuyboehm
Copy link
Contributor Author

It is ok now?

@matz3 matz3 merged commit fb1217a into SAP:master Feb 21, 2022
@matz3
Copy link
Member

matz3 commented Feb 21, 2022

Released via @ui5/builder v2.11.4 / @ui5/cli v2.14.6

matz3 pushed a commit that referenced this pull request Feb 25, 2022
RandomByte pushed a commit that referenced this pull request Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants