Allow updater save a function for each download

There are source that can be downloaded as archive, for example cloning
repositories with submodules. So how source are downloaded should be
changable per download.
This commit is contained in:
2023-10-28 03:31:10 +02:00
parent 6c0e2c2d24
commit fa6d93c5ca
2 changed files with 45 additions and 44 deletions

View File

@ -17,7 +17,6 @@ import qualified Text.URI as URI
import Crypto.Hash (Digest, MD5)
import SlackBuilder.Trans
import Control.Monad.Catch (MonadThrow)
import System.Process (CmdSpec(..))
-- | Contains information how a package can be updated.
data Package = Package
@ -25,7 +24,6 @@ data Package = Package
, downloaders :: [Updater]
, category :: Text
, name :: Text
, reupload :: Maybe [CmdSpec]
}
-- | Download URI with the MD5 checksum of the target.
@ -79,4 +77,7 @@ renderDownloadWithVersion (DownloadTemplate components) version =
f VersionPlaceholder = (version <>)
-- | Function used to get the latest version of a source.
data Updater = Updater (SlackBuilderT (Maybe Text)) DownloadTemplate
data Updater = Updater
{ detectLatest :: SlackBuilderT (Maybe Text)
, getVersion :: Text -> Text -> SlackBuilderT (URI, Digest MD5)
}