Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 2.09 KB

File metadata and controls

62 lines (39 loc) · 2.09 KB

Versioning

Please note that the code is WIP and might have not covered edge cases with unexpected behavior.

Semantic Version

An implementation of Semantic Version 2.0.0 specs. To be used for the mod version defined in the mods manifest.
There is one change compared to the specs as this implementations allows a v or V to be the first character, though that gets stripped of.

Version Comparator

This was intended to be used with manifest dependencies version.
As I did not find a specification I choose to use the npm semver sugar as inspiration.

For readability there is one space allowed between the operator and version >= 1 == >=1

This implementation ignores pre-release and build-metadata of an semantic version when comparing.

Also note that validation is currently not really done, apart from printing errors, so if the version range gets an invalid range pattern its comparators are either empty or if it had multiple ranges separated by the logical or only comparators for valid ranges.

Usage

var comp := VersionRange.new(">= 1")
var semver := SemanticVersion.parse("1.5.6")

if comp.check(semver):
    print("Satisfies the range")

Logical operator

The ranges separated by a space are interpreted as logical and.
While || is a logical or, allowing for rather complex version ranges to be defined.
Note that for the or operator the spaces on the left and right side are needed.

X-Range

x|X|* as wildcard
=1.* -> =1.*.* -> >=1.0.0 <=2.0.0

Partial version

=1 -> =1.*.* -> >=1.0.0 <2.0.0

Hyphen range

1 - 2 -> >=1.0.0 <=2.*.* -> >=1.0.0 <3.0.0

Tilde range

Allows for patch level changes, this is different to npms implementation but offers a clearer expected behavior. ~1.2.3 -> >=1.2.3 <1.3.0 ~1 -> >=1.0.0 <1.1.0

Caret range

Allows for minor level changes, this is different to npms implementation but offers a clearer expected behavior. ^1.2.3 -> >=1.2.3 <2.0.0 ^1 -> ``