Semver 比较器与检查器
关于
语义化版本(semver.org)赋予版本号一个契约:MAJOR 用于破坏性变更,MINOR 用于向后兼容的功能,PATCH 用于向后兼容的修复——加上预发布后缀(1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta < 1.0.0) and +build metadata that never affects precedence. The comparator implements the spec's precedence algorithm exactly, including the fiddly pre-release rules (numeric identifiers compare numerically and rank below alphanumeric ones; a version with a pre-release is older than the same version without). It is the check CI pipelines and package managers run millions of times a day.
常见问题
1.0.0-alpha 比 1.0.0 新吗?
不会——预发布版本比其正式版本旧:1.0.0-alpha < 1.0.0。正是这一规则让包管理器能安全地提供测试版。
+build 元数据重要吗?
不影响优先级:1.0.0+exp 和 1.0.0 在顺序上相等,不过元数据会保留以供参考。