WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Update UI incorrectly compares prelease semantic versions #3061

Open benfrancis opened 1 year ago

benfrancis commented 1 year ago

STR:

Expected:

Actual:

It appears that the compareSemver() function at https://github.com/WebThingsIO/gateway/blob/c378371d9f0dc5796287d469b8d67b5a6b56df07/static/js/views/settings.js#L1290 incorrectly thinks that 1.1.0-beta.2 is newer than 1.1.0.

Note that this is inconsistent with tools/check-for-update.js which just assumes that the list of releases is in chronological order and looks for the first entry which isn't a draft or a pre-release (if pre-releases are not enabled).

Neither are really correct and we should be doing a proper comparison of semantic versions which supports pre-release suffixes.

benfrancis commented 1 year ago

This probably also explains #3054 since it doesn't think 1.1.0-beta.2 is newer than 1.1.0-alpha.2 (the output of the function is 0).

Note that this will mean users who installed a 1.1 pre-release won't be able to manually trigger an update to 1.1 in the UI, but their gateway will automatically update itself within 24 hours if automatic updates are enabled.

An alternative workaround is to manually run ./tools/check-for-update.sh on the command line.

benfrancis commented 1 year ago

See also https://github.com/WebThingsIO/gateway/blob/master/src/addon-utils.ts which uses yet another approach for comparing versions. For the purposes of checking add-on compatibility it currently ignores pre-release suffixes, but the semver library used there may be useful.