patriksvensson / cupboard

A framework for provisioning local environments to a desired state, using the .NET SDK.
MIT License
761 stars 19 forks source link

add PackageVersion to ChocolateyPackage and allow downgrade #31

Closed jetersen closed 2 years ago

patriksvensson commented 3 years ago

@jetersen Thanks for this pull request!

We also need to take the version number into account when deciding whether or not the specified package is installed, and only install if the version number is lower than the provided version number.

jetersen commented 3 years ago

Right, I'll look into that 😅

patriksvensson commented 3 years ago

@jetersen Version information should already be part of the choco list -lo we run to determine if a package is installed, so just some additional parsing is required there. We could use the semver crate to parse and compare the version.

jetersen commented 3 years ago

Chocolatey does not follow semver.

See just my chocolatey installs:

autohotkey.portable 1.1.33.09
chocolatey 0.11.1
chocolatey-core.extension 1.3.5.1
chocolatey-windowsupdate.extension 1.0.4
maven 3.8.2
ngrok 2.3.40
omnic.install 9.8.0
scc 3.0.0
sops 3.7.1
spacesniffer 1.3.0.2
patriksvensson commented 3 years ago

@jetersen Correct, but we will need semver for other parts of Cupboard, and if we're adding a dependency it might as well be a robust one that supports semver 😄

jetersen commented 3 years ago

I believe System.Version would suffice for chocolatey. No dependency added either.

patriksvensson commented 3 years ago

Ok, go with System.Version.

jetersen commented 2 years ago

@patriksvensson Tests should be good now 😊

I chose to use Span methods directly because behind the scene most string methods get turned into Span and Span slice is more favorable than substring. 🚀

jetersen commented 2 years ago

@patriksvensson I think this is good for a merge :)

patriksvensson commented 2 years ago

Merged! Thank you for your contribution. Much appreciated! 👍