yesod-bin 1.2.6.1 → 1.2.7
raw patch · 3 files changed
+32/−2 lines, 3 filesdep +filesystem-conduit
Dependencies added: filesystem-conduit
Files
- HsFile.hs +23/−0
- main.hs +6/−1
- yesod-bin.cabal +3/−1
+ HsFile.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE OverloadedStrings #-}+module HsFile (mkHsFile) where+import Text.ProjectTemplate (createTemplate)+import Data.Conduit + ( ($$), (=$), runResourceT, ResourceT, ConduitM, awaitForever, yield )+import qualified Data.Conduit.List as CL+import Data.Conduit.Filesystem (traverse, sourceFile)+import Prelude hiding (FilePath)+import Filesystem.Path ( FilePath )+import Filesystem.Path.CurrentOS ( encodeString )+import qualified Data.ByteString as BS+import Control.Monad.IO.Class (liftIO)++mkHsFile :: IO ()+mkHsFile = runResourceT $ traverse False "."+ $$ readIt+ =$ createTemplate + =$ awaitForever (liftIO . BS.putStr)++-- Reads a filepath from upstream and dumps a pair of (filepath, filecontents)+readIt :: ConduitM FilePath (FilePath, ResourceT IO BS.ByteString) (ResourceT IO) ()+readIt = CL.map $ \i -> (i, liftIO $ BS.readFile $ encodeString i)+
main.hs view
@@ -23,6 +23,7 @@ #ifndef WINDOWS import Build (touch)+import HsFile (mkHsFile) touch' :: IO () touch' = touch@@ -47,6 +48,7 @@ deriving (Show, Eq) data Command = Init { _initBare :: Bool }+ | HsFiles | Configure | Build { buildExtraArgs :: [String] } | Touch@@ -96,6 +98,7 @@ let cabal = rawSystem' (cabalCommand o) case optCommand o of Init bare -> scaffold bare+ HsFiles -> mkHsFile Configure -> cabal ["configure"] Build es -> touch' >> cabal ("build":es) Touch -> touch'@@ -124,8 +127,10 @@ <$> flag Cabal CabalDev ( long "dev" <> short 'd' <> help "use cabal-dev" ) <*> switch ( long "verbose" <> short 'v' <> help "More verbose output" ) <*> subparser ( command "init"- (info (Init <$> switch (long "bare" <> help "Create files in current folder"))+ (info (Init <$> (switch (long "bare" <> help "Create files in current folder"))) (progDesc "Scaffold a new site"))+ <> command "hsfiles" (info (pure HsFiles)+ (progDesc "Create a hsfiles file for the current folder")) <> command "configure" (info (pure Configure) (progDesc "Configure a project for building")) <> command "build" (info (Build <$> extraCabalArgs)
yesod-bin.cabal view
@@ -1,5 +1,5 @@ name: yesod-bin-version: 1.2.6.1+version: 1.2.7 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -90,6 +90,7 @@ , warp >= 1.3.7.5 , wai >= 1.4 , data-default-class+ , filesystem-conduit >= 1.0 && < 2.0 ghc-options: -Wall -threaded main-is: main.hs@@ -101,6 +102,7 @@ AddHandler Paths_yesod_bin Options+ HsFile source-repository head type: git