semver4j
semver4j copied to clipboard
NPM compatibility
The following checks throw an exception, while are regular constraints in npm
new Semver("0.0.7", SemverType.NPM).satisfies("~1.9.1-6")
new Semver("3.3.1", SemverType.NPM).satisfies(">=2.4.x")
new Semver("3.3.1alpha", SemverType.NPM).satisfies(">=2.4.0")
@algobardo any idea why? I don't have the time to look into it yet but if you figure out why and send a fix, I will gladly merge it!
i have the same problem, the issue is in: Requirement.evaluateReversePolishNotation(Requirement.java:357)
where a Range
is constructed with SemverType.LOOSE
even when the given type is NPM.
public Range(String version, RangeOperator op) {
this(new Semver(version, Semver.SemverType.LOOSE), op);
}
So none of the satisfies
methods work with ANY type except LOOSE , does not matter if u force NPM, or anything else....
new Semver("3.3.1", SemverType.NPM).satisfies(">=2.4.x")
fails and
new Semver("3.3.1", SemverType.NPM).satisfies(Requirement.buildNPM(">=2.4.x"))
fails as well, the Range
will always create a LOOSE
type which does not accept 'x' as patch notation...
maybe @vdurmont can help, this seems a serious problem... i integrated this library into a validator tool with dependencies of NPM style, and expected some basic functionality, like the satisfies
method, and reading versions and patch versions, nothing more, and got quite surprised it's not working even with the simple examples on the homepage... am i using it incorrectly ? if not, then we need to write some test cases... and i can help with fixing stuff, it's just i don't understand why you used Semver.SemverType.LOOSE
in the Range constructor, maybe there's a reason....
thanks much !!
Have you tried if the same happens on what we have https://github.com/algobardo/semver4j ? I attempted to solve some of the problems in #12
i don't want to repackage the library as artifact myself and i don't want to use the source code directly, so for the moment i patched my code not to use wildcards... thanks anyway.
@algobardo if you are still interesting, I've made copy of this lib and fix bug reported by you. Look for version 2.0.1