Add package tables to the configuration file
All checks were successful
Build / audit (push) Successful in 7s
Build / test (push) Successful in 15m14s

This commit is contained in:
Eugen Wissner 2024-09-20 22:34:17 +02:00
parent ae63ff0cc0
commit 2a78256933
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
3 changed files with 19 additions and 3 deletions

View File

@ -6,6 +6,7 @@
module SlackBuilder.Config
( Settings(..)
, MaintainerSettings(..)
, PackageSettings(..)
, settingsCodec
) where
@ -21,12 +22,19 @@ data Settings = Settings
, downloadURL :: Text
, uploadCommand :: NonEmpty Text
, maintainer :: MaintainerSettings
, packages :: [PackageSettings]
} deriving (Eq, Show)
newtype MaintainerSettings = MaintainerSettings
{ signature :: Bool
} deriving (Eq, Show)
data PackageSettings = PackageSettings
{ name :: Text
, template :: Text
, is64 :: Bool
} deriving (Eq, Show)
settingsCodec :: Toml.TomlCodec Settings
settingsCodec = Settings
<$> Toml.text "gh_token" .= ghToken
@ -35,7 +43,14 @@ settingsCodec = Settings
<*> Toml.text "download_url" .= downloadURL
<*> Toml.arrayNonEmptyOf Toml._Text "upload_command" .= uploadCommand
<*> Toml.table maintainerSettingsCodec "maintainer" .= maintainer
<*> Toml.list packageSettingsCodec "package" .= packages
maintainerSettingsCodec :: Toml.TomlCodec MaintainerSettings
maintainerSettingsCodec = MaintainerSettings
<$> Toml.bool "signature" .= signature
packageSettingsCodec :: Toml.TomlCodec PackageSettings
packageSettingsCodec = PackageSettings
<$> Toml.text "name" .= name
<*> Toml.text "template" .= template
<*> Toml.bool "is64" .= is64

View File

@ -38,7 +38,7 @@ import Network.HTTP.Req
, useHttpsURI
, bsResponse
, POST(..)
, ReqBodyJson(..)
, ReqBodyJson(..), JsonResponse
)
import Text.URI (mkURI)
import SlackBuilder.Trans
@ -181,7 +181,8 @@ latestPackagist PackageOwner{..} = do
/: owner
/: name <> ".json"
in req GET uri NoReqBody jsonResponse mempty
let packagistPackages = packages $ responseBody packagistResponse
let packagistPackages = getField @"packages"
$ responseBody (packagistResponse :: JsonResponse PackagistResponse)
fullName = Text.intercalate "/" [owner, name]
pure $ HashMap.lookup fullName packagistPackages

View File

@ -158,7 +158,7 @@ autoUpdatable =
in Package.Updater
{ detectLatest = latestGitHub ghArguments "(v)\\."
, getVersion = reuploadWithTemplate template []
, is64 = True
, is64 = False
}
, name = "librsync"
, downloaders = mempty