fix version in service detail path

This commit is contained in:
Lucy Cifferello
2021-07-16 13:12:27 -04:00
committed by Keagan McClelland
parent 73ae0fcfbd
commit ef063c11e6
4 changed files with 10 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
!/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
/data CategoriesR GET -- get all marketplace categories
/data CategoriesR GET -- get all marketplace categories
/packages PackageListR GET -- filter marketplace services by various query params
/eos EosR GET -- get eos information
/version/latest VersionLatestR GET -- get latest version of apps in query param id

View File

@@ -295,9 +295,9 @@ getServiceDetails maybeVersion service = do
version <- case maybeVersion of
Nothing -> do
(_, version) <- runDB $ fetchLatestApp appId >>= errOnNothing status404 "service not found"
pure version
Just v -> pure v
let appDir = (<> "/") . (</> show (sVersionNumber $ entityVal version)) . (</> toS appId) $ appsDir
pure $ sVersionNumber $ entityVal version
Just v -> pure $ sVersionNumber $ entityVal v
let appDir = (<> "/") . (</> show version) . (</> toS appId) $ appsDir
let appExt = Extension (toS appId) :: Extension "s9pk"
manifest' <- handleS9ErrT $ getManifest appMgrDir appDir appExt
manifest <- case eitherDecode $ BS.fromStrict manifest' of
@@ -307,12 +307,12 @@ getServiceDetails maybeVersion service = do
sendResponseStatus status500 ("Internal Server Error" :: Text)
Right (a :: ServiceManifest) -> pure a
d <- traverse (mapDependencyMetadata appsDir appMgrDir domain) (HM.toList $ serviceManifestDependencies manifest)
let depPath = appsDir </> toS appId </> show version
$logInfo $ show appDir
-- @TODO uncomment when sdk icon working
-- icon <- decodeIcon appMgrDir depPath appExt
-- icon <- decodeIcon appMgrDir appDir appExt
let icon = [i|https://#{domain}/icons/#{appId}.png|]
instructions <- decodeInstructions appMgrDir depPath appExt
license <- decodeLicense appMgrDir depPath appExt
instructions <- decodeInstructions appMgrDir appDir appExt
license <- decodeLicense appMgrDir appDir appExt
pure $ ServiceRes
{ serviceResIcon = icon
, serviceResManifest = manifest -- TypedContent "application/json" (toContent manifest)
@@ -328,7 +328,6 @@ mapDependencyMetadata :: (MonadIO m, MonadHandler m) => FilePath -> FilePath ->
mapDependencyMetadata appsDir appmgrPath domain (appId, depInfo) = do
let ext = (Extension (toS appId) :: Extension "s9pk")
-- get best version from VersionRange of dependency
$logInfo $ show appsDir
version <- getBestVersion appsDir ext (serviceDependencyInfoVersion depInfo) >>= \case
Nothing -> sendResponseStatus status404 ("best version not found for dependent package " <> appId :: Text)
Just v -> pure v
@@ -339,7 +338,6 @@ mapDependencyMetadata appsDir appmgrPath domain (appId, depInfo) = do
pure (appId, DependencyInfo
{ dependencyInfoTitle = appId
, dependencyInfoIcon = icon
})
decodeIcon :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m URL

View File

@@ -208,6 +208,8 @@ parseVersion = do
-- >>> Atto.parseOnly parseRange "=2.3.4 1.2.3.4 - 2.3.4.5 (>3.0.0 || <3.4.5)"
-- Right =2.3.4 >=1.2.3.4 <=2.3.4.5 ((>3.0.0 || <3.4.5))
-- >>> Atto.parseOnly parseRange "0.2.6"
-- >>> Atto.parseOnly parseRange ">=2.14.1.1 <3.0.0"
-- Right >=2.14.1.1 <3.0.0
parseRange :: Atto.Parser VersionRange
parseRange = s <|> (Atto.char '*' *> pure Any) <|> (Anchor (Right EQ) <$> parseVersion)
where

View File

@@ -27,9 +27,6 @@ getBestVersion :: (MonadIO m, KnownSymbol a, MonadLogger m) => FilePath -> Exten
getBestVersion rootDir ext spec = do
-- @TODO change to db query?
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
$logInfo $ show appVersions
$logInfo $ show spec
$logInfo $ show ext
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory
$logInfo $ show satisfactory