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 在順序上相等,不過後設資料會保留以供參考。