summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-09-20 22:34:17 +0200
committerEugen Wissner <belka@caraus.de>2024-09-20 22:34:17 +0200
commit2a782569332a4f69437d0e1f247a2b595e1045ad (patch)
tree344e63b6198559a1b42220d7cb92c23193ba1c43
parentae63ff0cc007c9680e18717381c3a000d26275f4 (diff)
downloadslackbuilder-2a782569332a4f69437d0e1f247a2b595e1045ad.tar.gz
Add package tables to the configuration file
-rw-r--r--lib/SlackBuilder/Config.hs15
-rw-r--r--lib/SlackBuilder/LatestVersionCheck.hs5
-rw-r--r--src/Main.hs2
3 files changed, 19 insertions, 3 deletions
diff --git a/lib/SlackBuilder/Config.hs b/lib/SlackBuilder/Config.hs
index 8e627e3..7160215 100644
--- a/lib/SlackBuilder/Config.hs
+++ b/lib/SlackBuilder/Config.hs
@@ -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
diff --git a/lib/SlackBuilder/LatestVersionCheck.hs b/lib/SlackBuilder/LatestVersionCheck.hs
index 523451e..874cd14 100644
--- a/lib/SlackBuilder/LatestVersionCheck.hs
+++ b/lib/SlackBuilder/LatestVersionCheck.hs
@@ -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
diff --git a/src/Main.hs b/src/Main.hs
index 4929e7e..38fbff2 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -158,7 +158,7 @@ autoUpdatable =
in Package.Updater
{ detectLatest = latestGitHub ghArguments "(v)\\."
, getVersion = reuploadWithTemplate template []
- , is64 = True
+ , is64 = False
}
, name = "librsync"
, downloaders = mempty