Add package tables to the configuration file
This commit is contained in:
parent
ae63ff0cc0
commit
2a78256933
@ -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
|
||||
|
@ -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
|
||||
|
@ -158,7 +158,7 @@ autoUpdatable =
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||
, getVersion = reuploadWithTemplate template []
|
||||
, is64 = True
|
||||
, is64 = False
|
||||
}
|
||||
, name = "librsync"
|
||||
, downloaders = mempty
|
||||
|
Loading…
Reference in New Issue
Block a user