mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
fix version in service detail path
This commit is contained in:
committed by
Keagan McClelland
parent
2ee06007c7
commit
9c8f236095
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
!/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
|
!/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
|
/packages PackageListR GET -- filter marketplace services by various query params
|
||||||
/eos EosR GET -- get eos information
|
/eos EosR GET -- get eos information
|
||||||
/version/latest VersionLatestR GET -- get latest version of apps in query param id
|
/version/latest VersionLatestR GET -- get latest version of apps in query param id
|
||||||
|
|||||||
@@ -295,9 +295,9 @@ getServiceDetails maybeVersion service = do
|
|||||||
version <- case maybeVersion of
|
version <- case maybeVersion of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
(_, version) <- runDB $ fetchLatestApp appId >>= errOnNothing status404 "service not found"
|
(_, version) <- runDB $ fetchLatestApp appId >>= errOnNothing status404 "service not found"
|
||||||
pure version
|
pure $ sVersionNumber $ entityVal version
|
||||||
Just v -> pure v
|
Just v -> pure $ sVersionNumber $ entityVal v
|
||||||
let appDir = (<> "/") . (</> show (sVersionNumber $ entityVal version)) . (</> toS appId) $ appsDir
|
let appDir = (<> "/") . (</> show version) . (</> toS appId) $ appsDir
|
||||||
let appExt = Extension (toS appId) :: Extension "s9pk"
|
let appExt = Extension (toS appId) :: Extension "s9pk"
|
||||||
manifest' <- handleS9ErrT $ getManifest appMgrDir appDir appExt
|
manifest' <- handleS9ErrT $ getManifest appMgrDir appDir appExt
|
||||||
manifest <- case eitherDecode $ BS.fromStrict manifest' of
|
manifest <- case eitherDecode $ BS.fromStrict manifest' of
|
||||||
@@ -307,12 +307,12 @@ getServiceDetails maybeVersion service = do
|
|||||||
sendResponseStatus status500 ("Internal Server Error" :: Text)
|
sendResponseStatus status500 ("Internal Server Error" :: Text)
|
||||||
Right (a :: ServiceManifest) -> pure a
|
Right (a :: ServiceManifest) -> pure a
|
||||||
d <- traverse (mapDependencyMetadata appsDir appMgrDir domain) (HM.toList $ serviceManifestDependencies manifest)
|
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
|
-- @TODO uncomment when sdk icon working
|
||||||
-- icon <- decodeIcon appMgrDir depPath appExt
|
-- icon <- decodeIcon appMgrDir appDir appExt
|
||||||
let icon = [i|https://#{domain}/icons/#{appId}.png|]
|
let icon = [i|https://#{domain}/icons/#{appId}.png|]
|
||||||
instructions <- decodeInstructions appMgrDir depPath appExt
|
instructions <- decodeInstructions appMgrDir appDir appExt
|
||||||
license <- decodeLicense appMgrDir depPath appExt
|
license <- decodeLicense appMgrDir appDir appExt
|
||||||
pure $ ServiceRes
|
pure $ ServiceRes
|
||||||
{ serviceResIcon = icon
|
{ serviceResIcon = icon
|
||||||
, serviceResManifest = manifest -- TypedContent "application/json" (toContent manifest)
|
, 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
|
mapDependencyMetadata appsDir appmgrPath domain (appId, depInfo) = do
|
||||||
let ext = (Extension (toS appId) :: Extension "s9pk")
|
let ext = (Extension (toS appId) :: Extension "s9pk")
|
||||||
-- get best version from VersionRange of dependency
|
-- get best version from VersionRange of dependency
|
||||||
$logInfo $ show appsDir
|
|
||||||
version <- getBestVersion appsDir ext (serviceDependencyInfoVersion depInfo) >>= \case
|
version <- getBestVersion appsDir ext (serviceDependencyInfoVersion depInfo) >>= \case
|
||||||
Nothing -> sendResponseStatus status404 ("best version not found for dependent package " <> appId :: Text)
|
Nothing -> sendResponseStatus status404 ("best version not found for dependent package " <> appId :: Text)
|
||||||
Just v -> pure v
|
Just v -> pure v
|
||||||
@@ -339,7 +338,6 @@ mapDependencyMetadata appsDir appmgrPath domain (appId, depInfo) = do
|
|||||||
pure (appId, DependencyInfo
|
pure (appId, DependencyInfo
|
||||||
{ dependencyInfoTitle = appId
|
{ dependencyInfoTitle = appId
|
||||||
, dependencyInfoIcon = icon
|
, dependencyInfoIcon = icon
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
decodeIcon :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m URL
|
decodeIcon :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m URL
|
||||||
|
|||||||
@@ -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)"
|
-- >>> 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))
|
-- 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 "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 :: Atto.Parser VersionRange
|
||||||
parseRange = s <|> (Atto.char '*' *> pure Any) <|> (Anchor (Right EQ) <$> parseVersion)
|
parseRange = s <|> (Atto.char '*' *> pure Any) <|> (Anchor (Right EQ) <$> parseVersion)
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ getBestVersion :: (MonadIO m, KnownSymbol a, MonadLogger m) => FilePath -> Exten
|
|||||||
getBestVersion rootDir ext spec = do
|
getBestVersion rootDir ext spec = do
|
||||||
-- @TODO change to db query?
|
-- @TODO change to db query?
|
||||||
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
|
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
|
||||||
$logInfo $ show appVersions
|
|
||||||
$logInfo $ show spec
|
|
||||||
$logInfo $ show ext
|
|
||||||
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
|
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
|
||||||
let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory
|
let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory
|
||||||
$logInfo $ show satisfactory
|
$logInfo $ show satisfactory
|
||||||
|
|||||||
Reference in New Issue
Block a user