Add a test module
This commit is contained in:
@ -30,6 +30,7 @@ data SlackBuilderCommand
|
||||
| DownloadCommand Text String
|
||||
| CloneCommand Text Text Text
|
||||
| DownloadAndDeployCommand Text Text
|
||||
| Up2DateCommand
|
||||
deriving (Eq, Show)
|
||||
|
||||
data PackagistArguments = PackagistArguments
|
||||
@ -75,6 +76,7 @@ slackBuilderCommand = subparser
|
||||
<> command "download" (info downloadCommand mempty)
|
||||
<> command "clone" (info cloneCommand mempty)
|
||||
<> command "deploy" (info deployCommand mempty)
|
||||
<> command "up2date" (info up2DateCommand mempty)
|
||||
where
|
||||
slackBuildCommand = SlackBuildCommand
|
||||
<$> argument str (metavar "PATH")
|
||||
@ -98,3 +100,4 @@ slackBuilderCommand = subparser
|
||||
deployCommand = DownloadAndDeployCommand
|
||||
<$> argument str (metavar "URI")
|
||||
<*> argument str (metavar "TARBALL")
|
||||
up2DateCommand = pure Up2DateCommand
|
||||
|
@ -7,6 +7,7 @@ module SlackBuilder.Download
|
||||
, hostedSources
|
||||
, remoteFileExists
|
||||
, updateSlackBuildVersion
|
||||
, uploadCommand
|
||||
) where
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
|
@ -1,13 +1,15 @@
|
||||
module SlackBuilder.Package
|
||||
( DownloadPlaceholder(..)
|
||||
, Download(..)
|
||||
, DownloadTemplate(..)
|
||||
, PackageInfo(..)
|
||||
, Maintainer(..)
|
||||
, Updater(..)
|
||||
, infoTemplate
|
||||
, renderDownloadWithVersion
|
||||
) where
|
||||
|
||||
import Data.List.NonEmpty (NonEmpty)
|
||||
import Data.List.NonEmpty (NonEmpty(..))
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import Text.URI (URI(..))
|
||||
@ -17,6 +19,7 @@ import GHC.Records (HasField(..))
|
||||
import System.FilePath (takeBaseName)
|
||||
import Data.List (partition)
|
||||
import SlackBuilder.Trans
|
||||
import Control.Monad.Catch (MonadThrow)
|
||||
|
||||
-- | Download URI with the MD5 checksum of the target.
|
||||
data Download = Download
|
||||
@ -60,8 +63,15 @@ instance Show DownloadTemplate
|
||||
where
|
||||
show (DownloadTemplate components) = concatMap show components
|
||||
|
||||
renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI
|
||||
renderDownloadWithVersion (DownloadTemplate components) version =
|
||||
URI.mkURI $ foldr f "" components
|
||||
where
|
||||
f (StaticPlaceholder staticPlaceholder) accumulator = accumulator <> staticPlaceholder
|
||||
f VersionPlaceholder accumulator = accumulator <> version
|
||||
|
||||
-- | Function used to get the latest version of a source.
|
||||
newtype Updater = Updater (SlackBuilderT (Maybe Text))
|
||||
data Updater = Updater (SlackBuilderT (Maybe Text)) DownloadTemplate
|
||||
|
||||
packageName :: PackageInfo -> Text
|
||||
packageName PackageInfo{ path } = Text.pack $ takeBaseName path
|
||||
|
Reference in New Issue
Block a user