Skip to content

Introduce version constraints #13

@shazib-summar

Description

@shazib-summar

SemVer has this neat little concept of version constraints where something like "2.3.x" would indicate any version that is >= 2.3.0 AND < 2.4.0

This is really helpful when ensuring a version is within a range. Say your project has a dependency but you don't want any bot or dependency management tool to suggest a version that is beyond a certain range.

I have not seen a "constraint" object in any of the other CalVer libs or the spec at calver.org, as they do not seem to be properly maintained. So lets add it here.

To make things not overwhelming, we can limit the format in which a constraint string can be specified. Otherwise there would be too much ground to cover in one step. Lets go with the following predicates

  • >
  • <
  • <=
  • >=

for now. These would cover like 90% of the real world use-cases. This means that we need to add the functionality to understand, create and check if a version matches any of the following types of constraint strings

  • "> MAJOR.MINOR.MICRO"
  • "< MAJOR.MINOR.MICRO"
  • ">= MAJOR.MINOR.MICRO"
  • ">= MAJOR.MINOR.MICRO"

Once we have this, it would be super easy to handle a comma separated list of such constraints "> a.b.c, <= d.e.f" which is the end goal here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions