re-organize files for case insensitive fs

This commit is contained in:
Greg Weber 2011-08-25 06:32:35 -07:00
parent 06bda2877e
commit 822a507f28
8 changed files with 70 additions and 64 deletions

View File

@ -1,5 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
module Scaffold.Build
module Build
( touch
, getDeps
, touchDeps

View File

@ -1,5 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
module Scaffold.Devel
module Devel
( devel
) where
@ -13,7 +13,7 @@ import Distribution.Verbosity (normal)
import Distribution.PackageDescription.Parse (readPackageDescription, readHookedBuildInfo)
import Distribution.PackageDescription (emptyHookedBuildInfo)
-- import Distribution.Simple.LocalBuildInfo (localPkgDescr)
import Scaffold.Build (getDeps, touchDeps, findHaskellFiles)
import Build (getDeps, touchDeps, findHaskellFiles)
-- import Network.Wai.Handler.Warp (run)
-- import Network.Wai.Middleware.Debug (debug)
-- import Distribution.Text (display)

View File

@ -1,7 +1,7 @@
{-# LANGUAGE TemplateHaskell #-}
-- | A code generation template haskell. Everything is taken as literal text,
-- with ~var~ variable interpolation.
module CodeGen (codegen, codegenDir) where
module Scaffolding.CodeGen (codegen, codegenDir) where
import Language.Haskell.TH.Syntax
import Text.ParserCombinators.Parsec

View File

@ -1,31 +1,20 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}
import CodeGen
import System.IO
import System.Directory
import qualified Data.ByteString.Char8 as S
module Scaffolding.Scaffolder (scaffold) where
import Scaffolding.CodeGen
import Language.Haskell.TH.Syntax
import Data.Time (getCurrentTime, utctDay, toGregorian)
import Data.Char (toLower)
import Control.Applicative ((<$>))
import qualified Data.ByteString.Lazy as L
import Control.Monad (unless)
import qualified Data.Text.Lazy as LT
import qualified Data.Text.Lazy.Encoding as LT
import Control.Monad (unless)
import System.Environment (getArgs)
import System.Exit (exitWith)
import Scaffold.Build (touch)
import Scaffold.Devel (devel)
import System.Process (rawSystem)
qq :: String
#if __GLASGOW_HASKELL__ >= 700
qq = ""
#else
qq = "$"
#endif
import qualified Data.ByteString.Lazy as L
import Control.Applicative ((<$>))
import qualified Data.ByteString.Char8 as S
import Data.Time (getCurrentTime, utctDay, toGregorian)
import Data.Char (toLower)
import System.Directory
import System.IO
prompt :: (String -> Bool) -> IO String
prompt f = do
@ -36,42 +25,23 @@ prompt f = do
putStrLn "That was not a valid entry, please try again: "
prompt f
main :: IO ()
main = do
args' <- getArgs
let (isDev, args) =
case args' of
"--dev":rest -> (True, rest)
_ -> (False, args')
let cmd = if isDev then "cabal-dev" else "cabal"
let cabal rest = rawSystem cmd rest >> return ()
let build rest = rawSystem cmd $ "build":rest
case args of
["init"] -> scaffold
"build":rest -> touch >> build rest >>= exitWith
["touch"] -> touch
["devel"] -> devel cabal
["version"] -> putStrLn "0.9"
"configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
_ -> do
putStrLn "Usage: yesod <command>"
putStrLn "Available commands:"
putStrLn " init Scaffold a new site"
putStrLn " configure Configure a project for building"
putStrLn " build Build project (performs TH dependency analysis)"
putStrLn " touch Touch any files with altered TH dependencies but do not build"
putStrLn " devel Run project with the devel server"
putStrLn " version Print the version of Yesod"
puts :: String -> IO ()
puts s = putStr s >> hFlush stdout
qq :: String
#if __GLASGOW_HASKELL__ >= 700
qq = ""
#else
qq = "$"
#endif
data Backend = Sqlite | Postgresql | MongoDB | Tiny
deriving (Eq, Read, Show, Enum, Bounded)
puts :: String -> IO ()
puts s = putStr s >> hFlush stdout
backends :: [Backend]
backends = [minBound .. maxBound]
scaffold :: IO ()
scaffold = do
puts $(codegenDir "input" "welcome")

35
yesod/main.hs Normal file
View File

@ -0,0 +1,35 @@
import Scaffolding.Scaffolder
import System.Environment (getArgs)
import System.Exit (exitWith)
import Build (touch)
import Devel (devel)
import System.Process (rawSystem)
main :: IO ()
main = do
args' <- getArgs
let (isDev, args) =
case args' of
"--dev":rest -> (True, rest)
_ -> (False, args')
let cmd = if isDev then "cabal-dev" else "cabal"
let cabal rest = rawSystem cmd rest >> return ()
let build rest = rawSystem cmd $ "build":rest
case args of
["init"] -> scaffold
"build":rest -> touch >> build rest >>= exitWith
["touch"] -> touch
["devel"] -> devel cabal
["version"] -> putStrLn "0.9"
"configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
_ -> do
putStrLn "Usage: yesod <command>"
putStrLn "Available commands:"
putStrLn " init Scaffold a new site"
putStrLn " configure Configure a project for building"
putStrLn " build Build project (performs TH dependency analysis)"
putStrLn " touch Touch any files with altered TH dependencies but do not build"
putStrLn " devel Run project with the devel server"
putStrLn " version Print the version of Yesod"

View File

@ -1,3 +1,3 @@
#!/bin/bash -x
rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd ..
rm -rf foobar && runghc main.hs init && cd foobar && cabal install && cabal install -fdevel && cd ..

View File

@ -1,6 +1,6 @@
# Important! run with test/run.sh
rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd ..
rm -rf foobar && runghc main.hs init && cd foobar && cabal install && cabal install -fdevel && cd ..
<<<
Michael
foobar
@ -10,7 +10,7 @@ t
>>> /.*Registering foobar-0.0.0.*/
>>>= 0
rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd ..
rm -rf foobar && runghc main.hs init && cd foobar && cabal install && cabal install -fdevel && cd ..
<<<
Michael
foobar
@ -20,7 +20,7 @@ s
>>> /.*Registering foobar-0.0.0.*/
>>>= 0
rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd .. && rm -rf foobar
rm -rf foobar && runghc main.hs init && cd foobar && cabal install && cabal install -fdevel && cd .. && rm -rf foobar
<<<
Michael
foobar

View File

@ -99,10 +99,11 @@ executable yesod
, blaze-builder >= 0.2 && < 0.4
, process
ghc-options: -Wall -threaded
main-is: scaffold.hs
other-modules: CodeGen
Scaffold.Build
Scaffold.Devel
main-is: main.hs
other-modules: Scaffolding.CodeGen
Scaffolding.Scaffolder
Devel
Build
source-repository head
type: git