Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Plugin Update Checker #1121

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Neuheit
Copy link
Contributor

@Neuheit Neuheit commented Dec 10, 2024

Adds a plugin update checker function to PluginManager.kt that runs on application startup

Closes #1044

The function checks the maven repository of each plugin declaration and searches the maven metadata file for the latest version. If then compares the latest version and current version installed and writes to the console if the user needs to update. The 3rd party library "semver" is used as a dependency to compare versions.

@@ -65,6 +65,7 @@ dependencies {
implementation(libs.kotlin.reflect)
implementation(libs.logback)
implementation(libs.sentry.logback)
implementation(libs.semver)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this lib really needed? we already have a way to parse semver in

you would just need to add a method to compare them which should be easy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didnt see this thanks!

Comment on lines 99 to 118
val connection = URL(basePath).openConnection() as HttpURLConnection
connection.inputStream.bufferedReader().use {
val lines = it.readLines()
for (line in lines) {
val regex = "<latest>(.*?)</latest>".toRegex()
val match = regex.find(line)
val latest = match?.groups?.get(1)?.value
if (latest != null) {
val latestVersion = latest.toVersion()
val currentVersion = declaration.version.toVersion()

if(latestVersion > currentVersion) {
log.warn("A newer version of ${declaration.name} was found: $latestVersion. " +
"The current version is $currentVersion.")
} else {
log.info("Plugin ${declaration.name} is up to date")
}
break
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please not regex XML?
With #1049 we want to parse the maven-metadata.xml anyway

@Neuheit Neuheit force-pushed the feature/plugin-update-verifier branch from 3c3b547 to 26bf4bf Compare December 25, 2024 22:04
@Neuheit Neuheit requested a review from topi314 December 26, 2024 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants