-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
196 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Confer.Cmd.Deploy (deploy) where | ||
|
||
import Control.Placeholder | ||
import Data.Vector (Vector) | ||
import Effectful | ||
import Control.Monad | ||
import Effectful.FileSystem (FileSystem) | ||
import Effectful.FileSystem qualified as FileSystem | ||
import System.OsPath (OsPath, (</>)) | ||
import System.OsPath qualified as OsPath | ||
|
||
import Confer.Effect.Symlink | ||
import Confer.Config.Types | ||
-- | Take a filtered and checked list of deployments. | ||
-- | ||
-- For each fact, we perform sequentially: | ||
-- * Check that the desired file exists | ||
-- * Check that the target symlink does not exist | ||
-- * If it exists, make sure that it points to the | ||
-- file that is version controlled | ||
-- * If it does not, raise an error | ||
deploy | ||
:: ( FileSystem :> es | ||
, Symlink :> es | ||
, IOE :> es | ||
) | ||
=> Vector Deployment | ||
-> Eff es () | ||
deploy deployments = do | ||
forM_ deployments $ \d -> | ||
forM_ d.facts $ \fact -> do | ||
let osPath = fact.destination </> fact.source | ||
filepath <- liftIO $ OsPath.decodeFS osPath | ||
exists <- FileSystem.doesPathExist filepath | ||
unless exists $ | ||
createSymlink fact.source fact.destination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.