summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-10-20 15:53:48 +0200
committerEugen Wissner <belka@caraus.de>2023-10-20 15:53:48 +0200
commit3a6d17952b247682f1cb794ef27b26c9b007f00d (patch)
treedfbfd7fe8ad4bba5084b6d5de7c9f97b010d5c51 /app
parent4105ffa91f85d66e631383211b5d074b04fc0d3c (diff)
downloadslackbuilder-3a6d17952b247682f1cb794ef27b26c9b007f00d.tar.gz
Allow looking on the text page for the latest version
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs21
-rw-r--r--app/SlackBuilder/CommandLine.hs11
-rw-r--r--app/SlackBuilder/Updater.hs6
3 files changed, 31 insertions, 7 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 99be344..27ae118 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -2,6 +2,8 @@ module Main
( main
) where
+import Data.Char (isNumber)
+import Control.Applicative (Applicative(liftA2))
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import Control.Monad.IO.Class (MonadIO(..))
@@ -147,6 +149,25 @@ autoUpdatable =
, name = "rdiff-backup"
, reupload = Just mempty
}
+ , Package
+ { latest =
+ let needle = "Linux—"
+ textArguments = TextArguments
+ { textURL = "https://help.webex.com/en-us/article/mqkve8/Webex-App-%7C-Release-notes"
+ , versionPicker = Text.takeWhile (liftA2 (||) (== '.') isNumber)
+ . Text.drop (Text.length needle)
+ . snd
+ . Text.breakOn needle
+ }
+ latest' = latestText textArguments
+ template = Package.DownloadTemplate $ pure
+ $ Package.StaticPlaceholder
+ "https://binaries.webex.com/WebexDesktop-Ubuntu-Official-Package/Webex.deb"
+ in Package.Updater latest' template
+ , category = "network"
+ , name = "webex"
+ , reupload = Nothing
+ }
]
up2Date :: SlackBuilderT ()
diff --git a/app/SlackBuilder/CommandLine.hs b/app/SlackBuilder/CommandLine.hs
index 1375b6e..53a6bfb 100644
--- a/app/SlackBuilder/CommandLine.hs
+++ b/app/SlackBuilder/CommandLine.hs
@@ -7,6 +7,7 @@ module SlackBuilder.CommandLine
) where
import Data.Text (Text)
+import qualified Data.Text as Text
import Options.Applicative
( Parser
, ParserInfo(..)
@@ -29,7 +30,6 @@ data SlackBuilderCommand
| CloneCommand Text Text Text
| DownloadAndDeployCommand Text Text
| Up2DateCommand
- deriving (Eq, Show)
data PackagistArguments = PackagistArguments
{ vendor :: Text
@@ -42,11 +42,14 @@ data GhArguments = GhArguments
, transform :: Maybe Text
} deriving (Eq, Show)
-newtype TextArguments = TextArguments Text
- deriving (Eq, Show)
+data TextArguments = TextArguments
+ { versionPicker :: Text -> Text
+ , textURL :: Text
+ }
textArguments :: Parser TextArguments
-textArguments = TextArguments <$> argument str (metavar "URL")
+textArguments = TextArguments Text.strip
+ <$> argument str (metavar "URL")
slackBuilderParser :: ParserInfo SlackBuilderCommand
slackBuilderParser = info slackBuilderCommand fullDesc
diff --git a/app/SlackBuilder/Updater.hs b/app/SlackBuilder/Updater.hs
index 864e466..1ebf7fe 100644
--- a/app/SlackBuilder/Updater.hs
+++ b/app/SlackBuilder/Updater.hs
@@ -107,11 +107,11 @@ latestPackagist PackagistArguments{..} = do
>>= fmap (version . fst) . Vector.uncons
latestText :: TextArguments -> SlackBuilderT (Maybe Text)
-latestText (TextArguments textArguments) = do
- uri <- liftIO $ useHttpsURI <$> mkURI textArguments
+latestText TextArguments{..} = do
+ uri <- liftIO $ useHttpsURI <$> mkURI textURL
packagistResponse <- traverse (runReq defaultHttpConfig . go . fst) uri
- pure $ Text.strip . Text.Encoding.decodeASCII . responseBody
+ pure $ versionPicker . Text.Encoding.decodeUtf8 . responseBody
<$> packagistResponse
where
go uri = req GET uri NoReqBody bsResponse mempty