-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A deployment library for Haskell applications
--   
--   Hapistrano makes it easy to reliably deploy Haskell applications to a
--   server.
--   
--   Following popular libraries like Ruby's
--   &lt;<a>http://capistranorb.com/</a> Capistrano&gt;, Hapistrano does
--   the work of building the application with dependencies into a distinct
--   folder, and then atomically moves a symlink to the latest complete
--   build.
--   
--   This allows for atomic switchovers to new application code after the
--   build is complete. Rollback is even simpler, since Hapistrano can just
--   point the <a>current</a> symlink to the previous release.
--   
--   See <a>the project readme on GitHub</a> for more information.
@package hapistrano
@version 0.3.5.7


-- | Type definitions for the Hapistrano tool.
module System.Hapistrano.Types

-- | Hapistrano monad.
type Hapistrano a = ExceptT Failure (ReaderT Config IO) a

-- | Failure with status code and a message.
data Failure
Failure :: Int -> (Maybe String) -> Failure

-- | Hapistrano configuration options.
data Config
Config :: !(Maybe SshOptions) -> !(OutputDest -> String -> IO ()) -> Config

-- | <a>Nothing</a> if we are running locally, or SSH options to use.
[configSshOptions] :: Config -> !(Maybe SshOptions)

-- | How to print messages
[configPrint] :: Config -> !(OutputDest -> String -> IO ())

-- | The records describes deployment task.
data Task
Task :: Path Abs Dir -> String -> String -> ReleaseFormat -> Task

-- | The root of the deploy target on the remote host
[taskDeployPath] :: Task -> Path Abs Dir

-- | The URL of remote Git repo to deploy
[taskRepository] :: Task -> String

-- | A SHA1 or branch to release
[taskRevision] :: Task -> String

-- | The <a>ReleaseFormat</a> to use
[taskReleaseFormat] :: Task -> ReleaseFormat

-- | Release format mode.
data ReleaseFormat

-- | Standard release path following Capistrano's format
ReleaseShort :: ReleaseFormat

-- | Long release path including picoseconds
ReleaseLong :: ReleaseFormat

-- | SSH options.
data SshOptions
SshOptions :: String -> Word -> SshOptions

-- | Host to use
[sshHost] :: SshOptions -> String

-- | Port to use
[sshPort] :: SshOptions -> Word

-- | Output destination.
data OutputDest
StdoutDest :: OutputDest
StderrDest :: OutputDest

-- | Release indentifier.
data Release

-- | Target's system where application will be deployed
data TargetSystem
GNULinux :: TargetSystem
BSD :: TargetSystem

-- | Create a <a>Release</a> indentifier.
mkRelease :: ReleaseFormat -> UTCTime -> Release

-- | Extract deployment time from <a>Release</a>.
releaseTime :: Release -> UTCTime

-- | Render <a>Release</a> indentifier as a <a>String</a>.
renderRelease :: Release -> String

-- | Parse <a>Release</a> identifier from a <a>String</a>.
parseRelease :: String -> Maybe Release
instance GHC.Enum.Enum System.Hapistrano.Types.TargetSystem
instance GHC.Enum.Bounded System.Hapistrano.Types.TargetSystem
instance GHC.Classes.Ord System.Hapistrano.Types.TargetSystem
instance GHC.Read.Read System.Hapistrano.Types.TargetSystem
instance GHC.Show.Show System.Hapistrano.Types.TargetSystem
instance GHC.Classes.Eq System.Hapistrano.Types.TargetSystem
instance GHC.Classes.Ord System.Hapistrano.Types.Release
instance GHC.Show.Show System.Hapistrano.Types.Release
instance GHC.Classes.Eq System.Hapistrano.Types.Release
instance GHC.Enum.Enum System.Hapistrano.Types.OutputDest
instance GHC.Enum.Bounded System.Hapistrano.Types.OutputDest
instance GHC.Classes.Ord System.Hapistrano.Types.OutputDest
instance GHC.Read.Read System.Hapistrano.Types.OutputDest
instance GHC.Show.Show System.Hapistrano.Types.OutputDest
instance GHC.Classes.Eq System.Hapistrano.Types.OutputDest
instance GHC.Classes.Ord System.Hapistrano.Types.SshOptions
instance GHC.Classes.Eq System.Hapistrano.Types.SshOptions
instance GHC.Read.Read System.Hapistrano.Types.SshOptions
instance GHC.Show.Show System.Hapistrano.Types.SshOptions
instance GHC.Classes.Ord System.Hapistrano.Types.Task
instance GHC.Classes.Eq System.Hapistrano.Types.Task
instance GHC.Show.Show System.Hapistrano.Types.Task
instance GHC.Enum.Bounded System.Hapistrano.Types.ReleaseFormat
instance GHC.Enum.Enum System.Hapistrano.Types.ReleaseFormat
instance GHC.Classes.Ord System.Hapistrano.Types.ReleaseFormat
instance GHC.Classes.Eq System.Hapistrano.Types.ReleaseFormat
instance GHC.Read.Read System.Hapistrano.Types.ReleaseFormat
instance GHC.Show.Show System.Hapistrano.Types.ReleaseFormat


-- | Collection of type safe shell commands that can be fed into
--   <a>runCommand</a>.
module System.Hapistrano.Commands

-- | Class for data types that represent shell commands in typed way.
class Command a where {
    type family Result a :: *;
}

-- | How to render the command before feeding it into shell (possibly via
--   SSH).
renderCommand :: Command a => a -> String

-- | How to parse the result from stdout.
parseResult :: Command a => Proxy a -> String -> Result a

-- | Unix <tt>whoami</tt>.
data Whoami
Whoami :: Whoami

-- | Specify directory in which to perform another command.
data Cd cmd
Cd :: (Path Abs Dir) -> cmd -> Cd cmd

-- | Create a directory. Does not fail if the directory already exists.
data MkDir
MkDir :: (Path Abs Dir) -> MkDir

-- | Delete file or directory.
data Rm
[Rm] :: Path Abs t -> Rm

-- | Move or rename files or directories.
data Mv t
Mv :: TargetSystem -> (Path Abs t) -> (Path Abs t) -> Mv t

-- | Create symlinks.
data Ln
[Ln] :: TargetSystem -> Path Abs t -> Path Abs File -> Ln

-- | <tt>ls</tt>, so far used only to check existence of directories, so
--   it's not very functional right now.
data Ls
Ls :: (Path Abs Dir) -> Ls

-- | Read link.
data Readlink t
Readlink :: TargetSystem -> (Path Abs File) -> Readlink t

-- | Find (a very limited version).
data Find t
Find :: Natural -> (Path Abs Dir) -> Find t

-- | <tt>touch</tt>.
data Touch
Touch :: (Path Abs File) -> Touch

-- | Git checkout.
data GitCheckout
GitCheckout :: String -> GitCheckout

-- | Git clone.
data GitClone
GitClone :: Bool -> (Either String (Path Abs Dir)) -> (Path Abs Dir) -> GitClone

-- | Git fetch (simplified).
data GitFetch
GitFetch :: String -> GitFetch

-- | Git reset.
data GitReset
GitReset :: String -> GitReset

-- | Weakly-typed generic command, avoid using it directly.
data GenericCommand

-- | Smart constructor that allows to create <a>GenericCommand</a>s. Just a
--   little bit more safety.
mkGenericCommand :: String -> Maybe GenericCommand

-- | Get the raw command back from <a>GenericCommand</a>.
unGenericCommand :: GenericCommand -> String

-- | Read commands from a file.
readScript :: MonadIO m => Path Abs File -> m [GenericCommand]
instance GHC.Classes.Ord System.Hapistrano.Commands.GenericCommand
instance GHC.Classes.Eq System.Hapistrano.Commands.GenericCommand
instance GHC.Show.Show System.Hapistrano.Commands.GenericCommand
instance GHC.Classes.Ord System.Hapistrano.Commands.Whoami
instance GHC.Classes.Eq System.Hapistrano.Commands.Whoami
instance GHC.Show.Show System.Hapistrano.Commands.Whoami
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.GenericCommand
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.GitReset
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.GitFetch
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.GitClone
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.GitCheckout
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.Touch
instance System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Find Path.Dir)
instance System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Find Path.File)
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.Ls
instance System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Readlink Path.File)
instance System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Readlink Path.Dir)
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.Ln
instance System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Mv Path.File)
instance System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Mv Path.Dir)
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.Rm
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.MkDir
instance System.Hapistrano.Commands.Command cmd => System.Hapistrano.Commands.Command (System.Hapistrano.Commands.Cd cmd)
instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.Whoami


-- | Core Hapistrano functions that provide basis on which all the
--   functionality is built.
module System.Hapistrano.Core

-- | Run the <a>Hapistrano</a> monad. The monad hosts <a>exec</a> actions.
runHapistrano :: MonadIO m => Maybe SshOptions -> (OutputDest -> String -> IO ()) -> Hapistrano a -> m (Either Int a)

-- | Fail returning the following status code and message.
failWith :: Int -> Maybe String -> Hapistrano a

-- | Run the given sequence of command. Whether to use SSH or not is
--   determined from settings contained in the <a>Hapistrano</a> monad
--   configuration. Commands that return non-zero exit codes will result in
--   short-cutting of execution.
exec :: forall a. Command a => a -> Hapistrano (Result a)

-- | Copy a file from local path to target server.
scpFile :: Path Abs File -> Path Abs File -> Hapistrano ()

-- | Copy a local directory recursively to target server.
scpDir :: Path Abs Dir -> Path Abs Dir -> Hapistrano ()


-- | A module for creating reliable deploy processes for Haskell
--   applications.
module System.Hapistrano

-- | Perform basic setup for a project, making sure necessary directories
--   exist and pushing a new release directory with the SHA1 or branch
--   specified in the configuration. Return identifier of the pushed
--   release.
pushRelease :: Task -> Hapistrano Release

-- | Same as <a>pushRelease</a> but doesn't perform any version control
--   related operations.
pushReleaseWithoutVc :: Task -> Hapistrano Release

-- | Create a file-token that will tell rollback function that this release
--   should be considered successfully compiled/completed.
registerReleaseAsComplete :: Path Abs Dir -> Release -> Hapistrano ()

-- | Switch the current symlink to point to the specified release. May be
--   used in deploy or rollback cases.
activateRelease :: TargetSystem -> Path Abs Dir -> Release -> Hapistrano ()

-- | Activates one of already deployed releases.
rollback :: TargetSystem -> Path Abs Dir -> Natural -> Hapistrano ()

-- | Remove older releases to avoid filling up the target host filesystem.
dropOldReleases :: Path Abs Dir -> Natural -> Hapistrano ()

-- | Play the given script switching to directory of given release.
playScript :: Path Abs Dir -> Release -> [GenericCommand] -> Hapistrano ()

-- | Plays the given script on your machine locally.
playScriptLocally :: [GenericCommand] -> Hapistrano ()

-- | Construct path to a particular <a>Release</a>.
releasePath :: Path Abs Dir -> Release -> Hapistrano (Path Abs Dir)

-- | Get full path to current symlink.
currentSymlinkPath :: Path Abs Dir -> Path Abs File

-- | Get full path to temp symlink.
tempSymlinkPath :: Path Abs Dir -> Path Abs File

-- | Get path to completion token file for particular release.
ctokenPath :: Path Abs Dir -> Release -> Hapistrano (Path Abs File)
