emver for registry appears complete, more testing required but should be ready for beta testing

This commit is contained in:
Keagan McClelland
2020-10-28 17:43:36 -06:00
parent 8cad3095fa
commit 28edfc2f87
16 changed files with 416 additions and 298 deletions

View File

@@ -9,14 +9,16 @@ import Yesod.Core
import Foundation
import Lib.Registry
import Lib.Semver
import Lib.Types.Semver
import Lib.Types.Emver
import Data.Semigroup
getVersionFromQuery :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe AppVersion)
getVersionFromQuery :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe Version)
getVersionFromQuery rootDir ext = do
specString <- T.filter (not . isSpace) . fromMaybe "*" <$> lookupGetParam "spec"
spec <- case readMaybe specString of
Nothing -> sendResponseStatus status400 ("Invalid App Version Specification" :: Text)
Just t -> pure t
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
pure $ version <$> getSpecifiedAppVersion spec appVersions
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory
pure best