|
@@ -12,10 +12,13 @@ LATEST="$2"
|
|
|
|
|
|
|
|
[ "$CURRENT" = "$LATEST" ] && { echo 0; exit 0; }
|
|
[ "$CURRENT" = "$LATEST" ] && { echo 0; exit 0; }
|
|
|
|
|
|
|
|
-# npx semver:latest 满足 >current 时输出自身,否则输出空
|
|
|
|
|
-# simp: 借 npm 生态 semver 实现,避免自写版本比较(prerelease 如 0.1.0-rc.6 的排序规则易错)
|
|
|
|
|
|
|
+# npx semver 无参时按优先级升序打印;latest 排最后则严格更新
|
|
|
|
|
+# simp: 借 npm 生态 semver 做纯排序,不用 range。>current 默认只匹配同元组
|
|
|
|
|
+# prerelease(0.1.1-rc.2 不满足 >0.1.0-rc.7),正是自动升级卡住的原因
|
|
|
#
|
|
#
|
|
|
-# npx semver: echoes latest when it satisfies >current, otherwise empty
|
|
|
|
|
-# simp: reuse the npm semver CLI instead of hand-rolling comparison (prerelease ordering like 0.1.0-rc.6 is error-prone)
|
|
|
|
|
-UPDATED="$(npx --yes semver@7 -r ">$CURRENT" "$LATEST" 2>/dev/null || true)"
|
|
|
|
|
-[ -n "$UPDATED" ] && echo 1 || echo 0
|
|
|
|
|
|
|
+# npx semver with no flags prints versions in ascending precedence; latest is
|
|
|
|
|
+# strictly newer if it sorts last. simp: reuse npm semver as a pure sort, not a
|
|
|
|
|
+# range. >current by default only matches same-tuple prereleases (0.1.1-rc.2
|
|
|
|
|
+# does not satisfy >0.1.0-rc.7 — why auto-upgrade stalled)
|
|
|
|
|
+HIGHER="$(npx --yes semver@7 "$CURRENT" "$LATEST" 2>/dev/null | tail -n1 || true)"
|
|
|
|
|
+[ "$HIGHER" = "$LATEST" ] && echo 1 || echo 0
|