mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
merge add package header
This commit is contained in:
committed by
Keagan McClelland
parent
40e7d5f097
commit
8f20f68c5e
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/apps AppsManifestR GET -- get current apps listing
|
||||
/package/manifest/#AppIdentifier AppManifestR GET -- get app manifest from appmgr -- ?spec={semver-spec}
|
||||
/package/config/#AppIdentifier AppConfigR GET -- get app config from appmgr -- ?spec={semver-spec}
|
||||
/package/manifest/#AppIdentifier AppManifestR GET -- get app manifest from appmgr -- ?spec={semver-spec}
|
||||
/package/config/#AppIdentifier AppConfigR GET -- get app config from appmgr -- ?spec={semver-spec}
|
||||
|
||||
/version VersionR GET
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ getAppManifestR appId = do
|
||||
Just v -> pure v
|
||||
let appDir = (<> "/") . (</> show av) . (</> toS appId) $ appsDir
|
||||
manifest <- handleS9ErrT $ getManifest appMgrDir appDir appExt
|
||||
addPackageHeader appMgrDir appDir appExt
|
||||
pure $ TypedContent "application/json" (toContent manifest)
|
||||
where appExt = Extension (toS appId) :: Extension "s9pk"
|
||||
|
||||
@@ -124,6 +125,7 @@ getAppConfigR appId = do
|
||||
Just v -> pure v
|
||||
let appDir = (<> "/") . (</> show av) . (</> toS appId) $ appsDir
|
||||
config <- handleS9ErrT $ getConfig appMgrDir appDir appExt
|
||||
addPackageHeader appMgrDir appDir appExt
|
||||
pure $ TypedContent "application/json" (toContent config)
|
||||
where appExt = Extension (toS appId) :: Extension "s9pk"
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import Data.Aeson
|
||||
import qualified Data.ByteString.Lazy as BS
|
||||
import qualified Data.Text as T
|
||||
import Data.String.Interpolate.IsString
|
||||
import Util.Shared
|
||||
|
||||
|
||||
newtype CategoryRes = CategoryRes {
|
||||
@@ -206,6 +207,7 @@ getServiceR = do
|
||||
-- let deps = HM.toList (versionInfoDependencies $ Data.List.head versionInfo)
|
||||
d <- traverse (mapDependencyMetadata appsDir appMgrDir) (HM.toList $ serviceManifestDependencies manifest)
|
||||
icon <- decodeIcon appMgrDir appsDir appExt
|
||||
addPackageHeader appMgrDir appDir appExt
|
||||
pure $ ServiceRes
|
||||
{ serviceResIcon = icon
|
||||
, serviceResManifest = manifest -- TypedContent "application/json" (toContent manifest)
|
||||
|
||||
9
src/Lib/External/AppMgr.hs
vendored
9
src/Lib/External/AppMgr.hs
vendored
@@ -61,4 +61,11 @@ getIcon appmgrPath appPath e@(Extension icon) = do
|
||||
(ec, bs) <- readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "icon", appPath <> show e] ""
|
||||
case ec of
|
||||
ExitSuccess -> pure bs
|
||||
ExitFailure n -> throwE $ AppMgrE [i|icon #{icon} \--json|] n
|
||||
ExitFailure n -> throwE $ AppMgrE [i|icon #{icon} \--json|] n
|
||||
|
||||
getPackageHash :: (MonadIO m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> S9ErrT m ByteString
|
||||
getPackageHash appmgrPath appPath e@(Extension appId) = do
|
||||
(ec, bs) <- readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "hash", appPath <> show e] ""
|
||||
case ec of
|
||||
ExitSuccess -> pure bs
|
||||
ExitFailure n -> throwE $ AppMgrE [i|hash #{appId} \--json|] n
|
||||
@@ -3,6 +3,7 @@ module Util.Shared where
|
||||
import Startlude hiding (Handler)
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Encoding
|
||||
import Network.HTTP.Types
|
||||
import Yesod.Core
|
||||
|
||||
@@ -10,6 +11,8 @@ import Foundation
|
||||
import Lib.Registry
|
||||
import Lib.Types.Emver
|
||||
import Data.Semigroup
|
||||
import Lib.External.AppMgr
|
||||
import Lib.Error
|
||||
|
||||
getVersionFromQuery :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe Version)
|
||||
getVersionFromQuery rootDir ext = do
|
||||
@@ -24,4 +27,9 @@ getBestVersion rootDir ext spec = do
|
||||
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
|
||||
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
|
||||
let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory
|
||||
pure best
|
||||
pure best
|
||||
|
||||
addPackageHeader :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m ()
|
||||
addPackageHeader appMgrDir appDir appExt = do
|
||||
packageHash <- handleS9ErrT $ getPackageHash appMgrDir appDir appExt
|
||||
addHeader "X-S9PK-HASH" $ decodeUtf8 packageHash
|
||||
Reference in New Issue
Block a user