Call devel-server as separate executable
This commit is contained in:
parent
462c071ac4
commit
3251f8b6bc
63
Yesod.hs
63
Yesod.hs
@ -15,9 +15,7 @@ module Yesod
|
|||||||
-- * Running your application
|
-- * Running your application
|
||||||
, warp
|
, warp
|
||||||
, warpDebug
|
, warpDebug
|
||||||
#if !PRODUCTION
|
|
||||||
, develServer
|
, develServer
|
||||||
#endif
|
|
||||||
-- * Commonly referenced functions/datatypes
|
-- * Commonly referenced functions/datatypes
|
||||||
, Application
|
, Application
|
||||||
, lift
|
, lift
|
||||||
@ -62,9 +60,6 @@ import Yesod.Json
|
|||||||
import Yesod.Persist
|
import Yesod.Persist
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
import Network.Wai.Middleware.Debug
|
import Network.Wai.Middleware.Debug
|
||||||
#if !PRODUCTION
|
|
||||||
import Network.Wai.Handler.DevelServer (runQuit)
|
|
||||||
#endif
|
|
||||||
import Control.Monad.Trans.Class (lift)
|
import Control.Monad.Trans.Class (lift)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Control.Monad.IO.Peel (MonadPeelIO)
|
import Control.Monad.IO.Peel (MonadPeelIO)
|
||||||
@ -72,12 +67,6 @@ import Control.Monad.IO.Peel (MonadPeelIO)
|
|||||||
import Network.Wai.Handler.Warp (run)
|
import Network.Wai.Handler.Warp (run)
|
||||||
import System.IO (stderr, hPutStrLn)
|
import System.IO (stderr, hPutStrLn)
|
||||||
|
|
||||||
import qualified Data.Text.Lazy.IO as TIO
|
|
||||||
import qualified Data.Attoparsec.Text.Lazy as A
|
|
||||||
import Control.Applicative ((<|>))
|
|
||||||
import Data.Maybe (mapMaybe)
|
|
||||||
import Data.Char (isSpace)
|
|
||||||
|
|
||||||
showIntegral :: Integral a => a -> String
|
showIntegral :: Integral a => a -> String
|
||||||
showIntegral x = show (fromIntegral x :: Integer)
|
showIntegral x = show (fromIntegral x :: Integer)
|
||||||
|
|
||||||
@ -99,7 +88,6 @@ warpDebug port a = do
|
|||||||
hPutStrLn stderr $ "Application launched, listening on port " ++ show port
|
hPutStrLn stderr $ "Application launched, listening on port " ++ show port
|
||||||
toWaiApp a >>= run port . debug
|
toWaiApp a >>= run port . debug
|
||||||
|
|
||||||
#if !PRODUCTION
|
|
||||||
-- | Run a development server, where your code changes are automatically
|
-- | Run a development server, where your code changes are automatically
|
||||||
-- reloaded.
|
-- reloaded.
|
||||||
develServer :: Int -- ^ port number
|
develServer :: Int -- ^ port number
|
||||||
@ -107,45 +95,20 @@ develServer :: Int -- ^ port number
|
|||||||
-> String -- ^ name of function providing a with-application
|
-> String -- ^ name of function providing a with-application
|
||||||
-> IO ()
|
-> IO ()
|
||||||
|
|
||||||
develServer port modu func = do
|
develServer port modu func =
|
||||||
mapM_ putStrLn
|
mapM_ putStrLn
|
||||||
[ "Starting your server process. Code changes will be automatically"
|
[ "Due to issues with GHC 7.0.2, you must now run the devel server"
|
||||||
, "loaded as you save your files. Type \"quit\" to exit."
|
, "separately. To do so, ensure you have installed the "
|
||||||
, "You can view your app at http://localhost:" ++ show port ++ "/"
|
, "wai-handler-devel package >= 0.2.1 and run:"
|
||||||
|
, concat
|
||||||
|
[ " wai-handler-devel "
|
||||||
|
, show port
|
||||||
|
, " "
|
||||||
|
, modu
|
||||||
|
, " "
|
||||||
|
, func
|
||||||
|
, " --yesod"
|
||||||
|
]
|
||||||
, ""
|
, ""
|
||||||
]
|
]
|
||||||
runQuit port modu func determineHamletDeps
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
data TempType = Hamlet | Cassius | Julius | Widget
|
|
||||||
deriving Show
|
|
||||||
|
|
||||||
-- | Determine which Hamlet files a Haskell file depends upon.
|
|
||||||
determineHamletDeps :: FilePath -> IO [FilePath]
|
|
||||||
determineHamletDeps x = do
|
|
||||||
y <- TIO.readFile x
|
|
||||||
let z = A.parse (A.many $ (parser <|> (A.anyChar >> return Nothing))) y
|
|
||||||
case z of
|
|
||||||
A.Fail{} -> return []
|
|
||||||
A.Done _ r -> return $ mapMaybe go r
|
|
||||||
where
|
|
||||||
go (Just (Hamlet, f)) = Just $ "hamlet/" ++ f ++ ".hamlet"
|
|
||||||
go (Just (Widget, f)) = Just $ "hamlet/" ++ f ++ ".hamlet"
|
|
||||||
go _ = Nothing
|
|
||||||
parser = do
|
|
||||||
typ <- (A.string "$(hamletFile " >> return Hamlet)
|
|
||||||
<|> (A.string "$(cassiusFile " >> return Cassius)
|
|
||||||
<|> (A.string "$(juliusFile " >> return Julius)
|
|
||||||
<|> (A.string "$(widgetFile " >> return Widget)
|
|
||||||
<|> (A.string "$(Settings.hamletFile " >> return Hamlet)
|
|
||||||
<|> (A.string "$(Settings.cassiusFile " >> return Cassius)
|
|
||||||
<|> (A.string "$(Settings.juliusFile " >> return Julius)
|
|
||||||
<|> (A.string "$(Settings.widgetFile " >> return Widget)
|
|
||||||
A.skipWhile isSpace
|
|
||||||
_ <- A.char '"'
|
|
||||||
y <- A.many1 $ A.satisfy (/= '"')
|
|
||||||
_ <- A.char '"'
|
|
||||||
A.skipWhile isSpace
|
|
||||||
_ <- A.char ')'
|
|
||||||
return $ Just (typ, y)
|
|
||||||
|
|||||||
13
yesod.cabal
13
yesod.cabal
@ -1,5 +1,5 @@
|
|||||||
name: yesod
|
name: yesod
|
||||||
version: 0.7.1
|
version: 0.7.2
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
@ -18,21 +18,13 @@ extra-source-files: scaffold/*.cg
|
|||||||
|
|
||||||
flag ghc7
|
flag ghc7
|
||||||
|
|
||||||
flag production
|
|
||||||
Description: Skip the wai-handler-devel and hint dependencies.
|
|
||||||
Default: False
|
|
||||||
|
|
||||||
library
|
library
|
||||||
if flag(production)
|
|
||||||
cpp-options: -DPRODUCTION
|
|
||||||
else
|
|
||||||
build-depends: wai-handler-devel >= 0.2 && < 0.3
|
|
||||||
if flag(ghc7)
|
if flag(ghc7)
|
||||||
build-depends: base >= 4.3 && < 5
|
build-depends: base >= 4.3 && < 5
|
||||||
cpp-options: -DGHC7
|
cpp-options: -DGHC7
|
||||||
else
|
else
|
||||||
build-depends: base >= 4 && < 4.3
|
build-depends: base >= 4 && < 4.3
|
||||||
build-depends: yesod-core >= 0.7.0.1 && < 0.8
|
build-depends: yesod-core >= 0.7.0.2 && < 0.8
|
||||||
, yesod-auth >= 0.3 && < 0.4
|
, yesod-auth >= 0.3 && < 0.4
|
||||||
, yesod-json >= 0.0.0.1 && < 0.1
|
, yesod-json >= 0.0.0.1 && < 0.1
|
||||||
, yesod-persistent >= 0.0.0.1 && < 0.1
|
, yesod-persistent >= 0.0.0.1 && < 0.1
|
||||||
@ -46,7 +38,6 @@ library
|
|||||||
, warp >= 0.3.2.1 && < 0.4
|
, warp >= 0.3.2.1 && < 0.4
|
||||||
, mime-mail >= 0.1.0.1 && < 0.2
|
, mime-mail >= 0.1.0.1 && < 0.2
|
||||||
, hjsmin >= 0.0.12 && < 0.1
|
, hjsmin >= 0.0.12 && < 0.1
|
||||||
, attoparsec-text >= 0.8.2.1 && < 0.9
|
|
||||||
exposed-modules: Yesod
|
exposed-modules: Yesod
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user