No description
Find a file
2022-11-30 14:06:43 -06:00
src Add "Release" type, change all types to subtypes of RootObj 2022-11-30 14:06:43 -06:00
tests Add location URI to dependency 2022-11-19 12:39:05 -06:00
.gitignore Initial commit 2022-11-18 17:00:30 -06:00
CHANGELOG Add "Release" type, change all types to subtypes of RootObj 2022-11-30 14:06:43 -06:00
README.md Fix typo in README 2022-11-19 12:39:18 -06:00
resolver.nimble Add changelog, bump version to 0.2.0 2022-11-19 11:31:50 -06:00

resolver provides utilities for parsing semantic version strings, and managing dependency versions.

Example

import resolver, std/uri

let a = parseVersionRule("~= 1.0.0")
assert     a.matches("1.0.1")
assert not a.matches("1.1.0")
assert not a.matches("2.0.0")

let b = parseVersionRule("^= 1.0.0")
assert     b.matches("1.0.1")
assert     b.matches("1.1.0")
assert not b.matches("2.0.0")

let c = parseVersionRule(">= 1.0.0")
assert     c.matches("1.0.1")
assert     c.matches("1.1.0")
assert     c.matches("2.0.0")

let d = parseDependency("nim ^= 1.6.0")
assert not d.matches("flimflam", "1.6.0")
assert     d.matches("nim", "1.6.0")
assert     d.matches("nim", "1.7.0-alpha.2")
assert not d.matches("nim", "1.6.0-alpha.2")
assert     d.matches("nim", "1.7.0")
assert     d.matches("NIM", "1.7.0")
assert     d.matches("N_I_M", "1.7.0")

let f = parseDependency("nim >= 1.6.4 https://github.com/nim-lang/nim.git")
assert     f.matches("nim", "1.6.4")
assert     f.matches("nim", "1.7.5")
assert not f.matches("nim", "1.6.3")
assert $f.location == "https://github.com/nim-lang/nim.git"

Dependency Strings

Here are some valid dependency strings:

nim >= 1.6.0
nim ^= 1.6.0
nim ~= 1.6.0
nim ~= 1.6.0 and != 1.6.5

The following operators are supported:

  • >= (greater than or equal)
  • <= (less than or equal)
  • != (not equal to)
  • == (equal to)
  • ^= (optimistically compatible)
  • ~= (pessimistically compatible)
  • and (boolean AND)
  • or (boolean OR)

The "and" operator takes precedence over "or."

Pessimistic vs Optimistic Compatibility

The ~= and ^= operators both represent "compatibility," but ~= is more strict.

  • ~= requires the major AND minor version numbers to match the rule.
  • ^= requires only the major version number to match the rule.

Future plans

The existing API is not likely to change. However, this package will eventually provide more extensive tools for resolving, merging, and ordering dependencies.