Compare commits
No commits in common. "e9504fb8e56fe93e4e23c52b45a620432b11570b" and "49d6718fee3a230a09e47c11bf9b8563bbc28657" have entirely different histories.
e9504fb8e5
...
49d6718fee
@ -1,49 +0,0 @@
|
|||||||
name: Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
audit:
|
|
||||||
runs-on: alpine
|
|
||||||
steps:
|
|
||||||
- name: Set up environment
|
|
||||||
shell: ash {0}
|
|
||||||
run: |
|
|
||||||
apk add --no-cache git bash curl build-base readline-dev openssl-dev zlib-dev libpq-dev gmp-dev
|
|
||||||
- name: Prepare system
|
|
||||||
run: |
|
|
||||||
curl --create-dirs --output-dir \
|
|
||||||
~/.ghcup/bin https://downloads.haskell.org/~ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 -o ghcup
|
|
||||||
chmod +x ~/.ghcup/bin/ghcup
|
|
||||||
~/.ghcup/bin/ghcup install ghc 9.4.8
|
|
||||||
~/.ghcup/bin/ghcup install cabal 3.6.2.0
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal update
|
|
||||||
~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal install hlint --constraint="hlint ==3.6.1"
|
|
||||||
- run: ~/.cabal/bin/hlint -- src lib tests
|
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: alpine
|
|
||||||
steps:
|
|
||||||
- name: Set up environment
|
|
||||||
shell: ash {0}
|
|
||||||
run: |
|
|
||||||
apk add --no-cache git bash curl build-base readline-dev openssl-dev zlib-dev libpq-dev gmp-dev
|
|
||||||
- name: Prepare system
|
|
||||||
run: |
|
|
||||||
curl --create-dirs --output-dir \
|
|
||||||
~/.ghcup/bin https://downloads.haskell.org/~ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 -o ghcup
|
|
||||||
chmod +x ~/.ghcup/bin/ghcup
|
|
||||||
~/.ghcup/bin/ghcup install ghc 9.4.8
|
|
||||||
~/.ghcup/bin/ghcup install cabal 3.6.2.0
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal update
|
|
||||||
~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal build slackbuilder-test
|
|
||||||
- run: ~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal test --test-show-details=direct
|
|
@ -96,5 +96,3 @@ test-suite slackbuilder-test
|
|||||||
slackbuilder
|
slackbuilder
|
||||||
|
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
|
||||||
build-tool-depends:
|
|
||||||
hspec-discover:hspec-discover
|
|
||||||
|
39
src/Main.hs
39
src/Main.hs
@ -256,21 +256,12 @@ up2Date = for_ autoUpdatable go
|
|||||||
go package = getAndLogLatest package
|
go package = getAndLogLatest package
|
||||||
>>= mapM_ (updatePackageIfRequired package)
|
>>= mapM_ (updatePackageIfRequired package)
|
||||||
>> liftIO (putStrLn "")
|
>> liftIO (putStrLn "")
|
||||||
|
getAndLogLatest Package{ latest = Package.Updater{ detectLatest }, name }
|
||||||
|
= liftIO (putStrLn $ Text.unpack name <> ": Retreiving the latest version.")
|
||||||
|
>> detectLatest
|
||||||
|
|
||||||
check :: SlackBuilderT ()
|
updatePackageIfRequired :: Package -> Text -> SlackBuilderT ()
|
||||||
check = for_ autoUpdatable go
|
updatePackageIfRequired package@Package{..} version = do
|
||||||
where
|
|
||||||
go package = getAndLogLatest package
|
|
||||||
>>= mapM_ (checkUpdateAvailability package)
|
|
||||||
>> liftIO (putStrLn "")
|
|
||||||
|
|
||||||
getAndLogLatest :: Package -> SlackBuilderT (Maybe Text)
|
|
||||||
getAndLogLatest Package{ latest = Package.Updater{ detectLatest }, name }
|
|
||||||
= liftIO (putStrLn $ Text.unpack name <> ": Retreiving the latest version.")
|
|
||||||
>> detectLatest
|
|
||||||
|
|
||||||
checkUpdateAvailability :: Package -> Text -> SlackBuilderT (Maybe PackageInfo)
|
|
||||||
checkUpdateAvailability Package{..} version = do
|
|
||||||
let packagePath = Text.unpack category </> Text.unpack name </> (Text.unpack name <.> "info")
|
let packagePath = Text.unpack category </> Text.unpack name </> (Text.unpack name <.> "info")
|
||||||
repository' <- SlackBuilderT $ asks repository
|
repository' <- SlackBuilderT $ asks repository
|
||||||
infoContents <- liftIO $ ByteString.readFile $ repository' </> packagePath
|
infoContents <- liftIO $ ByteString.readFile $ repository' </> packagePath
|
||||||
@ -283,8 +274,7 @@ checkUpdateAvailability Package{..} version = do
|
|||||||
Text.IO.putStrLn
|
Text.IO.putStrLn
|
||||||
$ name <> " is up to date (Version " <> version <> ")."
|
$ name <> " is up to date (Version " <> version <> ")."
|
||||||
setSGR [Reset]
|
setSGR [Reset]
|
||||||
pure Nothing
|
| otherwise -> do
|
||||||
| otherwise ->
|
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
setSGR [SetColor Foreground Dull Yellow]
|
setSGR [SetColor Foreground Dull Yellow]
|
||||||
Text.IO.putStrLn
|
Text.IO.putStrLn
|
||||||
@ -292,14 +282,8 @@ checkUpdateAvailability Package{..} version = do
|
|||||||
<> name <> " " <> getField @"version" parsedInfoFile
|
<> name <> " " <> getField @"version" parsedInfoFile
|
||||||
<> " is available (" <> version <> ")."
|
<> " is available (" <> version <> ")."
|
||||||
setSGR [Reset]
|
setSGR [Reset]
|
||||||
pure $ Just parsedInfoFile
|
updatePackage package parsedInfoFile version
|
||||||
Left errorBundle -> liftIO (putStr $ errorBundlePretty errorBundle)
|
Left errorBundle -> liftIO $ putStr $ errorBundlePretty errorBundle
|
||||||
>> pure Nothing
|
|
||||||
|
|
||||||
updatePackageIfRequired :: Package -> Text -> SlackBuilderT ()
|
|
||||||
updatePackageIfRequired package version
|
|
||||||
= checkUpdateAvailability package version
|
|
||||||
>>= mapM_ (updatePackage package version)
|
|
||||||
|
|
||||||
updateDownload :: Package -> Package.Updater -> SlackBuilderT (Package.Download, Text)
|
updateDownload :: Package -> Package.Updater -> SlackBuilderT (Package.Download, Text)
|
||||||
updateDownload Package{..} Package.Updater{..} = do
|
updateDownload Package{..} Package.Updater{..} = do
|
||||||
@ -385,8 +369,8 @@ renderAndDownload Package{..} version = do
|
|||||||
|
|
||||||
getVersion packagePath version
|
getVersion packagePath version
|
||||||
|
|
||||||
updatePackage :: Package -> Text -> PackageInfo -> SlackBuilderT ()
|
updatePackage :: Package -> PackageInfo -> Text -> SlackBuilderT ()
|
||||||
updatePackage package@Package{..} version info = do
|
updatePackage package@Package{..} info version = do
|
||||||
let packagePath = category <> "/" <> name
|
let packagePath = category <> "/" <> name
|
||||||
|
|
||||||
repository' <- SlackBuilderT $ asks repository
|
repository' <- SlackBuilderT $ asks repository
|
||||||
@ -432,5 +416,6 @@ main = do
|
|||||||
categories <- liftIO $ findCategory repository'
|
categories <- liftIO $ findCategory repository'
|
||||||
liftIO $ print $ splitFileName . makeRelative repository' <$> categories
|
liftIO $ print $ splitFileName . makeRelative repository' <$> categories
|
||||||
pure Nothing
|
pure Nothing
|
||||||
CheckCommand -> check >> pure Nothing
|
CloneCommand repo tarball tagPrefix -> fmap (Text.pack . show)
|
||||||
|
<$> clone repo tarball tagPrefix
|
||||||
Up2DateCommand -> up2Date >> pure Nothing
|
Up2DateCommand -> up2Date >> pure Nothing
|
||||||
|
@ -21,7 +21,7 @@ import Options.Applicative
|
|||||||
|
|
||||||
data SlackBuilderCommand
|
data SlackBuilderCommand
|
||||||
= CategoryCommand Text
|
= CategoryCommand Text
|
||||||
| CheckCommand
|
| CloneCommand Text Text Text
|
||||||
| Up2DateCommand
|
| Up2DateCommand
|
||||||
|
|
||||||
data PackagistArguments = PackagistArguments
|
data PackagistArguments = PackagistArguments
|
||||||
@ -46,10 +46,13 @@ slackBuilderParser = info slackBuilderCommand fullDesc
|
|||||||
slackBuilderCommand :: Parser SlackBuilderCommand
|
slackBuilderCommand :: Parser SlackBuilderCommand
|
||||||
slackBuilderCommand = subparser
|
slackBuilderCommand = subparser
|
||||||
$ command "category" (info categoryCommand mempty)
|
$ command "category" (info categoryCommand mempty)
|
||||||
<> command "check" (info checkCommand mempty)
|
<> command "clone" (info cloneCommand mempty)
|
||||||
<> command "up2date" (info up2DateCommand mempty)
|
<> command "up2date" (info up2DateCommand mempty)
|
||||||
where
|
where
|
||||||
categoryCommand = CategoryCommand
|
categoryCommand = CategoryCommand
|
||||||
<$> argument str (metavar "PKGNAM")
|
<$> argument str (metavar "PKGNAM")
|
||||||
checkCommand = pure CheckCommand
|
cloneCommand = CloneCommand
|
||||||
|
<$> argument str (metavar "REPO")
|
||||||
|
<*> argument str (metavar "TARBALL")
|
||||||
|
<*> argument str (metavar "TAG_PREFIX")
|
||||||
up2DateCommand = pure Up2DateCommand
|
up2DateCommand = pure Up2DateCommand
|
||||||
|
Loading…
x
Reference in New Issue
Block a user