Strongly typed semver (https://semver.org) parser for Luau
Find a file
Erica Marigold fe321dda7b fix: return error on invalid ordinal with points
Previously, if the ordinal contained dots (like 1.2.3-beta.3.4.5),
although it was invalid, an error would not be returned, which was
problematic. This has now been fixed.

Test cases are also included to prevent future regressions.
2024-11-21 18:21:19 +00:00
.github/workflows chore(actions): use pesde auth login command instead of manually editing config 2024-11-12 21:20:03 +05:30
.lune chore(lune): migrate tests runner to use official frktest package 2024-11-12 20:20:55 +05:30
.vscode chore(vscode): remove trailing comma in JSON config 2024-11-12 20:25:33 +05:30
lib fix: return error on invalid ordinal with points 2024-11-21 18:21:19 +00:00
tests fix: return error on invalid ordinal with points 2024-11-21 18:21:19 +00:00
.gitignore chore: include .gitignore 2024-11-04 12:19:26 +05:30
.luaurc chore(luaurc): include pkg aliases for lune packages 2024-11-04 12:17:13 +05:30
LICENSE.md chore(LICENSE): replace copyright holder 2024-11-11 11:52:05 +05:30
pesde.toml chore(pkg): remove .git suffix in index urls 2024-11-12 21:47:12 +05:30
README.md chore(README): use raw url for lune badge for maximum compatibility 2024-11-12 21:48:30 +05:30

semver-luau

Discord Pesde Lune

A Luau library to parse and compare Semantic Versioning compatible version numbers.

Semantic Versioning (Semver) is a versioning scheme for software that uses a three-part version number format, MAJOR.MINOR.PATCH. Additionally, Semver defines rules on when to increment each of these parts:

  • MAJOR version increments indicate incompatible API changes.
  • MINOR version increments indicate the addition of functionality in a backward-compatible manner.
  • PATCH version increments indicate backward-compatible bug fixes.

Semver also allows for optional pre-release and build metadata tags.

For a detailed set of guidelines that Semver version numbers follow, visit the previously linked website containing the full Semver specification.

Usage

To improve error / nil handling ergnomics, this library makes use of util.luau's Option and Result implementations. Any fallible methods return a Result and potentially null values are represented as Options.

Invalid versions should return a Result with the respective error. If not, this is considered a bug, and please consider filing an issue here.

local semver = require("semver")

-- Parse version strings
local v1 = semver.parse("1.2.3"):unwrap() --[[
  major = 1,
  minor = 2,
  patch = 3,
  buildMetadata = Option::None,
  prerelease = Option::None
]]
local v2 = semver.parse("5.12.0+build.1731248766"):unwrap() --[[
  major = 5,
  minor = 12,
  patch = 0,
  buildMetadata = Option::Some("build.1731248766"),
  prerelease = Option::None
]]

-- Compare versions
print(v1 < v2)  -- true
print(v1 > v2)  -- false
print(v1 == v2) -- false

MSLV (Minimum Supported Luau Version)

This library requires at least requires at least Luau 0.629, which corresponds to Lune 0.8.7 (for leading | support).

License

This project is licensed under the MIT license.