Add package tables to the configuration file
This commit is contained in:
parent
ae63ff0cc0
commit
2a78256933
@ -6,6 +6,7 @@
|
|||||||
module SlackBuilder.Config
|
module SlackBuilder.Config
|
||||||
( Settings(..)
|
( Settings(..)
|
||||||
, MaintainerSettings(..)
|
, MaintainerSettings(..)
|
||||||
|
, PackageSettings(..)
|
||||||
, settingsCodec
|
, settingsCodec
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -21,12 +22,19 @@ data Settings = Settings
|
|||||||
, downloadURL :: Text
|
, downloadURL :: Text
|
||||||
, uploadCommand :: NonEmpty Text
|
, uploadCommand :: NonEmpty Text
|
||||||
, maintainer :: MaintainerSettings
|
, maintainer :: MaintainerSettings
|
||||||
|
, packages :: [PackageSettings]
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
newtype MaintainerSettings = MaintainerSettings
|
newtype MaintainerSettings = MaintainerSettings
|
||||||
{ signature :: Bool
|
{ signature :: Bool
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
data PackageSettings = PackageSettings
|
||||||
|
{ name :: Text
|
||||||
|
, template :: Text
|
||||||
|
, is64 :: Bool
|
||||||
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
settingsCodec :: Toml.TomlCodec Settings
|
settingsCodec :: Toml.TomlCodec Settings
|
||||||
settingsCodec = Settings
|
settingsCodec = Settings
|
||||||
<$> Toml.text "gh_token" .= ghToken
|
<$> Toml.text "gh_token" .= ghToken
|
||||||
@ -35,7 +43,14 @@ settingsCodec = Settings
|
|||||||
<*> Toml.text "download_url" .= downloadURL
|
<*> Toml.text "download_url" .= downloadURL
|
||||||
<*> Toml.arrayNonEmptyOf Toml._Text "upload_command" .= uploadCommand
|
<*> Toml.arrayNonEmptyOf Toml._Text "upload_command" .= uploadCommand
|
||||||
<*> Toml.table maintainerSettingsCodec "maintainer" .= maintainer
|
<*> Toml.table maintainerSettingsCodec "maintainer" .= maintainer
|
||||||
|
<*> Toml.list packageSettingsCodec "package" .= packages
|
||||||
|
|
||||||
maintainerSettingsCodec :: Toml.TomlCodec MaintainerSettings
|
maintainerSettingsCodec :: Toml.TomlCodec MaintainerSettings
|
||||||
maintainerSettingsCodec = MaintainerSettings
|
maintainerSettingsCodec = MaintainerSettings
|
||||||
<$> Toml.bool "signature" .= signature
|
<$> 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
|
, useHttpsURI
|
||||||
, bsResponse
|
, bsResponse
|
||||||
, POST(..)
|
, POST(..)
|
||||||
, ReqBodyJson(..)
|
, ReqBodyJson(..), JsonResponse
|
||||||
)
|
)
|
||||||
import Text.URI (mkURI)
|
import Text.URI (mkURI)
|
||||||
import SlackBuilder.Trans
|
import SlackBuilder.Trans
|
||||||
@ -181,7 +181,8 @@ latestPackagist PackageOwner{..} = do
|
|||||||
/: owner
|
/: owner
|
||||||
/: name <> ".json"
|
/: name <> ".json"
|
||||||
in req GET uri NoReqBody jsonResponse mempty
|
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]
|
fullName = Text.intercalate "/" [owner, name]
|
||||||
|
|
||||||
pure $ HashMap.lookup fullName packagistPackages
|
pure $ HashMap.lookup fullName packagistPackages
|
||||||
|
@ -158,7 +158,7 @@ autoUpdatable =
|
|||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||||
, getVersion = reuploadWithTemplate template []
|
, getVersion = reuploadWithTemplate template []
|
||||||
, is64 = True
|
, is64 = False
|
||||||
}
|
}
|
||||||
, name = "librsync"
|
, name = "librsync"
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
|
Loading…
Reference in New Issue
Block a user