Compare commits

..

No commits in common. "ec704e267b1344ca30654850b7d127198846d081" and "77c9a2ab54b697f37e21b76c1fd82fc42dc4792e" have entirely different histories.

6 changed files with 29 additions and 82 deletions

View File

@ -22,7 +22,6 @@ import Text.URI.QQ (uri)
import Data.Foldable (for_) import Data.Foldable (for_)
import qualified Text.URI as URI import qualified Text.URI as URI
import GHC.Records (HasField(..)) import GHC.Records (HasField(..))
import System.FilePath ((</>), (<.>))
data Package = Package data Package = Package
{ latest :: Package.Updater { latest :: Package.Updater
@ -78,20 +77,12 @@ updatePackage Package{..} version = do
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
let tarball = "slackbuilds/development/universal-ctags/ctags-#{version}.tar.gz" let tarball = "slackbuilds/development/universal-ctags/ctags-#{version}.tar.gz"
checksum <- fromMaybe undefined <$> download uri' tarball checksum <- fromMaybe undefined <$> download uri' tarball
download' <- liftIO download' <- liftIO $ mkURI "https://download.dlackware.com/hosted-sources/universal-ctags/ctags-#{version}.tar.gz"
$ mkURI
$ Text.replace "#{version}" version
"https://download.dlackware.com/hosted-sources/universal-ctags/ctags-#{version}.tar.gz"
repository' <- SlackBuilderT $ asks repository
let infoFilePath = repository' </> Text.unpack packagePath
</> (Text.unpack name <.> "info")
liftIO $ Text.IO.writeFile infoFilePath liftIO $ Text.IO.writeFile "slackbuilds/#{package.path}/#{package.name}.info"
$ Package.infoTemplate package' [Package.Download download' checksum False] $ Package.infoTemplate package' [Package.Download download' checksum False]
updateSlackBuildVersion packagePath version updateSlackBuildVersion packagePath version
uploadCommand (Text.pack tarball) "#{CONFIG[:remote_path]}/universal-ctags"
remotePath' <- SlackBuilderT $ asks remotePath
uploadCommand (Text.pack tarball) $ remotePath' <> "/universal-ctags"
commit packagePath version commit packagePath version

View File

@ -63,13 +63,12 @@ instance Show DownloadTemplate
where where
show (DownloadTemplate components) = concatMap show components show (DownloadTemplate components) = concatMap show components
-- | Replaces placeholders in the URL template with the given version.
renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI
renderDownloadWithVersion (DownloadTemplate components) version = renderDownloadWithVersion (DownloadTemplate components) version =
URI.mkURI $ foldr f "" components URI.mkURI $ foldr f "" components
where where
f (StaticPlaceholder staticPlaceholder) = (staticPlaceholder <>) f (StaticPlaceholder staticPlaceholder) accumulator = accumulator <> staticPlaceholder
f VersionPlaceholder = (version <>) f VersionPlaceholder accumulator = accumulator <> version
-- | Function used to get the latest version of a source. -- | Function used to get the latest version of a source.
data Updater = Updater (SlackBuilderT (Maybe Text)) DownloadTemplate data Updater = Updater (SlackBuilderT (Maybe Text)) DownloadTemplate

View File

@ -15,14 +15,16 @@ maintainer: belka@caraus.de
category: Build category: Build
extra-source-files: CHANGELOG.md extra-source-files: CHANGELOG.md
common dependencies executable slackbuilder
build-depends: main-is: Main.hs
base ^>= 4.16.4.0,
cryptonite >= 0.30, other-modules:
filepath ^>= 1.4.2, SlackBuilder.CommandLine
modern-uri ^>= 0.3.6, SlackBuilder.Config
text ^>= 2.0 SlackBuilder.Download
default-language: Haskell2010 SlackBuilder.Package
SlackBuilder.Trans
SlackBuilder.Updater
default-extensions: default-extensions:
DataKinds DataKinds
DuplicateRecordFields DuplicateRecordFields
@ -33,53 +35,35 @@ common dependencies
QuasiQuotes QuasiQuotes
TemplateHaskell TemplateHaskell
TypeApplications TypeApplications
library slackbuilder-internal
import: dependencies
exposed-modules:
SlackBuilder.Config
SlackBuilder.Package
SlackBuilder.Trans
hs-source-dirs: lib
build-depends:
exceptions >= 0.10,
tomland ^>= 1.3.3,
transformers ^>= 0.5.6
ghc-options: -Wall
executable slackbuilder
import: dependencies
main-is: Main.hs
other-modules:
SlackBuilder.CommandLine
SlackBuilder.Download
SlackBuilder.Updater
build-depends: build-depends:
aeson ^>= 2.2.0, aeson ^>= 2.2.0,
base ^>= 4.16.4.0,
bytestring ^>= 0.11.0, bytestring ^>= 0.11.0,
conduit ^>= 1.3.5, conduit ^>= 1.3.5,
cryptonite >= 0.30,
exceptions >= 0.10,
filepath ^>= 1.4.2,
http-client ^>= 0.7, http-client ^>= 0.7,
modern-uri ^>= 0.3.6,
optparse-applicative ^>= 0.18.1, optparse-applicative ^>= 0.18.1,
process ^>= 1.6.17, process ^>= 1.6.17,
req ^>= 3.13, req ^>= 3.13,
text ^>= 2.0,
tomland ^>= 1.3.3,
transformers ^>= 0.5.6,
unordered-containers ^>= 0.2.19, unordered-containers ^>= 0.2.19,
vector ^>= 0.13.0 vector ^>= 0.13.0
hs-source-dirs: app hs-source-dirs: app
default-language: Haskell2010
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
test-suite slackbuilder-test test-suite slackbuilder-test
import: dependencies
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: Spec.hs main-is: Spec.hs
hs-source-dirs:
other-modules: tests
SlackBuilder.PackageSpec
hs-source-dirs: tests
build-depends:
hspec >= 2.10.9 && < 2.12,
slackbuilder-internal
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
default-language: Haskell2010
build-depends:
hspec >= 2.10.9 && < 2.12

View File

@ -1,27 +0,0 @@
module SlackBuilder.PackageSpec
( spec
) where
import Data.List.NonEmpty (NonEmpty(..))
import SlackBuilder.Package
import Test.Hspec (Spec, describe, it, shouldBe)
import Text.URI.QQ (uri)
spec :: Spec
spec = do
describe "renderDownloadWithVersion" $ do
it "renders text as URL" $
let given = DownloadTemplate
$ pure
$ StaticPlaceholder "https://example.com"
actual = renderDownloadWithVersion given "1.2"
expected = Just [uri|https://example.com|]
in actual `shouldBe` expected
it "renders the components in order" $
let given = DownloadTemplate
$ StaticPlaceholder "https://example.com/"
:| [VersionPlaceholder, StaticPlaceholder "/segment"]
actual = renderDownloadWithVersion given "1.2"
expected = Just [uri|https://example.com/1.2/segment|]
in actual `shouldBe` expected