ci(custom-checks): node engine validation should not be hard coded
Describe the bug
This is about the script tools/custom-checks/check-package-json-fields.ts, which validates lots of fields in package.json, one of them is engine. The current behaviour is not correct and should be fixed as per expected behaviour below.
This check is commented in PR #3962 (Line 60-65).
But once the expected behaviour is implemented, this should be uncommented.
To Reproduce
Change engine field in any package.json, to not equal >=18. And the this check will fail.
Expected behavior
This check should understand the pattern and verify if the required version is greater than our desired number or not, instead of fixed hardcoded string match to >=18.
For e.g. If check says version should be >=18, then all the below patterns should pass as well:
-
>=20 -
>21 -
=23
and following should fail:
-
>=17
Other (weaker) acceptable solution is to have list of supported node engine versions, and any match in that list should be valid.
I'll copy paste my comment from discord for documentation purposes
This is to ensure that we require specific node version throughout entire project, so that there's no case where user uses nodejs 18, and after a while he gets an error from some other package, that now node 20 is required (because it's set as required in that package). The right way here is to bump all the packages to use node 20 so that user can use entire project with single setup
This issue will be considered if the depending package remains, as part of the cleanup initiative: https://github.com/hyperledger-cacti/cacti/issues/4037