Merge branch 'master' into yesod-1.4

This commit is contained in:
Michael Snoyman 2014-09-21 10:56:58 +03:00
commit f1de32ec68
7 changed files with 356 additions and 56 deletions

View File

@ -17,6 +17,8 @@ import qualified Codec.Archive.Tar as Tar
import Control.Exception
import qualified Data.ByteString.Lazy as L
import Codec.Compression.GZip (compress)
import qualified Data.Foldable as Fold
import Control.Monad.Trans.Writer (tell, execWriter)
run :: String -> [String] -> IO ()
run a b = do
@ -36,7 +38,12 @@ keter cabal noBuild = do
case Map.lookup "host" value of
Just (String s) | "<<" `T.isPrefixOf` s ->
error $ "Please set your hostname in " ++ ketercfg
_ -> return value
_ ->
case Map.lookup "user-edited" value of
Just (Bool False) ->
error $ "Please edit your Keter config file at "
++ ketercfg
_ -> return value
Just _ -> error $ ketercfg ++ " is not an object"
files <- getDirectoryContents "."
@ -46,10 +53,14 @@ keter cabal noBuild = do
[] -> error "No cabal file found"
_ -> error "Too many cabal files found"
exec <-
case Map.lookup "exec" value of
Just (String s) -> return $ F.collapse $ "config" F.</> F.fromText s
_ -> error $ "exec not found in " ++ ketercfg
let findExecs (Object v) =
mapM_ go $ Map.toList v
where
go ("exec", String s) = tell [F.collapse $ "config" F.</> F.fromText s]
go (_, v') = findExecs v'
findExecs (Array v) = Fold.mapM_ findExecs v
findExecs _ = return ()
execs = execWriter $ findExecs $ Object value
unless noBuild $ do
run cabal ["clean"]
@ -58,7 +69,7 @@ keter cabal noBuild = do
_ <- try' $ F.removeTree "static/tmp"
archive <- Tar.pack "" [F.encodeString exec, "config", "static"]
archive <- Tar.pack "" $ "config" : "static" : map F.encodeString execs
let fp = T.unpack project ++ ".keter"
L.writeFile fp $ compress $ Tar.write archive

View File

@ -705,15 +705,63 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
{-# START_FILE config/keter.yml #-}
exec: ../dist/build/PROJECTNAME/PROJECTNAME
args:
- production
host: <<HOST-NOT-SET>>
# After you've edited this file, remove the following line to allow
# `yesod keter` to build your bundle.
user-edited: false
# A Keter app is composed of 1 or more stanzas. The main stanza will define our
# web application. See the Keter documentation for more information on
# available stanzas.
stanzas:
# Your Yesod application.
- type: webapp
# Name of your executable. You are unlikely to need to change this.
# Note that all file paths are relative to the keter.yml file.
exec: ../dist/build/PROJECTNAME/PROJECTNAME
# Command line options passed to your application.
args:
- production
hosts:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
- www.PROJECTNAME.com
# Static files.
- type: static-files
hosts:
- static.PROJECTNAME.com
root: ../static
# Uncomment to turn on directory listings.
# directory-listing: true
# Redirect plain domain name to www.
- type: redirect
hosts:
- PROJECTNAME.com
actions:
- host: www.PROJECTNAME.com
# secure: false
# port: 80
# Uncomment to switch to a non-permanent redirect.
# status: 303
# Use the following to automatically copy your bundle upon creation via `yesod
# keter`. Uses `scp` internally, so you can set it to a remote destination
# copy-to: user@host:/opt/keter/incoming
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
# postgres: true
{-# START_FILE config/models #-}
User
ident Text

View File

@ -711,15 +711,63 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
{-# START_FILE config/keter.yml #-}
exec: ../dist/build/PROJECTNAME/PROJECTNAME
args:
- production
host: <<HOST-NOT-SET>>
# After you've edited this file, remove the following line to allow
# `yesod keter` to build your bundle.
user-edited: false
# A Keter app is composed of 1 or more stanzas. The main stanza will define our
# web application. See the Keter documentation for more information on
# available stanzas.
stanzas:
# Your Yesod application.
- type: webapp
# Name of your executable. You are unlikely to need to change this.
# Note that all file paths are relative to the keter.yml file.
exec: ../dist/build/PROJECTNAME/PROJECTNAME
# Command line options passed to your application.
args:
- production
hosts:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
- www.PROJECTNAME.com
# Static files.
- type: static-files
hosts:
- static.PROJECTNAME.com
root: ../static
# Uncomment to turn on directory listings.
# directory-listing: true
# Redirect plain domain name to www.
- type: redirect
hosts:
- PROJECTNAME.com
actions:
- host: www.PROJECTNAME.com
# secure: false
# port: 80
# Uncomment to switch to a non-permanent redirect.
# status: 303
# Use the following to automatically copy your bundle upon creation via `yesod
# keter`. Uses `scp` internally, so you can set it to a remote destination
# copy-to: user@host:/opt/keter/incoming
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
# postgres: true
{-# START_FILE config/models #-}
User
ident Text
@ -735,6 +783,15 @@ Email
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
{-# START_FILE config/mysql.yml #-}
# NOTE: These settings can be overridden by environment variables as well, in
# particular:
#
# MYSQL_HOST
# MYSQL_PORT
# MYSQL_USER
# MYSQL_PASSWORD
# MYSQL_DATABASE
Default: &defaults
user: PROJECTNAME
password: PROJECTNAME
@ -760,32 +817,6 @@ Production:
poolsize: 100
<<: *defaults
{-# START_FILE config/postgresql.yml #-}
Default: &defaults
user: PROJECTNAME
password: PROJECTNAME
host: localhost
port: 5432
database: PROJECTNAME
poolsize: 10
Development:
<<: *defaults
Testing:
database: PROJECTNAME_test
<<: *defaults
Staging:
database: PROJECTNAME_staging
poolsize: 100
<<: *defaults
Production:
database: PROJECTNAME_production
poolsize: 100
<<: *defaults
{-# START_FILE config/robots.txt #-}
User-agent: *

View File

@ -760,15 +760,63 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
{-# START_FILE config/keter.yml #-}
exec: ../dist/build/PROJECTNAME/PROJECTNAME
args:
- production
host: <<HOST-NOT-SET>>
# After you've edited this file, remove the following line to allow
# `yesod keter` to build your bundle.
user-edited: false
# A Keter app is composed of 1 or more stanzas. The main stanza will define our
# web application. See the Keter documentation for more information on
# available stanzas.
stanzas:
# Your Yesod application.
- type: webapp
# Name of your executable. You are unlikely to need to change this.
# Note that all file paths are relative to the keter.yml file.
exec: ../dist/build/PROJECTNAME/PROJECTNAME
# Command line options passed to your application.
args:
- production
hosts:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
- www.PROJECTNAME.com
# Static files.
- type: static-files
hosts:
- static.PROJECTNAME.com
root: ../static
# Uncomment to turn on directory listings.
# directory-listing: true
# Redirect plain domain name to www.
- type: redirect
hosts:
- PROJECTNAME.com
actions:
- host: www.PROJECTNAME.com
# secure: false
# port: 80
# Uncomment to switch to a non-permanent redirect.
# status: 303
# Use the following to automatically copy your bundle upon creation via `yesod
# keter`. Uses `scp` internally, so you can set it to a remote destination
# copy-to: user@host:/opt/keter/incoming
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
# postgres: true
{-# START_FILE config/models #-}
User
ident Text
@ -784,6 +832,15 @@ Email
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
{-# START_FILE config/postgresql.yml #-}
# NOTE: These settings can be overridden by environment variables as well, in
# particular:
#
# PGHOST
# PGPORT
# PGUSER
# PGPASS
# PGDATABASE
Default: &defaults
user: PROJECTNAME
password: PROJECTNAME

View File

@ -711,15 +711,63 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
{-# START_FILE config/keter.yml #-}
exec: ../dist/build/PROJECTNAME/PROJECTNAME
args:
- production
host: <<HOST-NOT-SET>>
# After you've edited this file, remove the following line to allow
# `yesod keter` to build your bundle.
user-edited: false
# A Keter app is composed of 1 or more stanzas. The main stanza will define our
# web application. See the Keter documentation for more information on
# available stanzas.
stanzas:
# Your Yesod application.
- type: webapp
# Name of your executable. You are unlikely to need to change this.
# Note that all file paths are relative to the keter.yml file.
exec: ../dist/build/PROJECTNAME/PROJECTNAME
# Command line options passed to your application.
args:
- production
hosts:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
- www.PROJECTNAME.com
# Static files.
- type: static-files
hosts:
- static.PROJECTNAME.com
root: ../static
# Uncomment to turn on directory listings.
# directory-listing: true
# Redirect plain domain name to www.
- type: redirect
hosts:
- PROJECTNAME.com
actions:
- host: www.PROJECTNAME.com
# secure: false
# port: 80
# Uncomment to switch to a non-permanent redirect.
# status: 303
# Use the following to automatically copy your bundle upon creation via `yesod
# keter`. Uses `scp` internally, so you can set it to a remote destination
# copy-to: user@host:/opt/keter/incoming
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
# postgres: true
{-# START_FILE config/models #-}
User
ident Text
@ -735,6 +783,15 @@ Email
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
{-# START_FILE config/postgresql.yml #-}
# NOTE: These settings can be overridden by environment variables as well, in
# particular:
#
# PGHOST
# PGPORT
# PGUSER
# PGPASS
# PGDATABASE
Default: &defaults
user: PROJECTNAME
password: PROJECTNAME

View File

@ -626,15 +626,63 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
{-# START_FILE config/keter.yml #-}
exec: ../dist/build/PROJECTNAME/PROJECTNAME
args:
- production
host: <<HOST-NOT-SET>>
# After you've edited this file, remove the following line to allow
# `yesod keter` to build your bundle.
user-edited: false
# A Keter app is composed of 1 or more stanzas. The main stanza will define our
# web application. See the Keter documentation for more information on
# available stanzas.
stanzas:
# Your Yesod application.
- type: webapp
# Name of your executable. You are unlikely to need to change this.
# Note that all file paths are relative to the keter.yml file.
exec: ../dist/build/PROJECTNAME/PROJECTNAME
# Command line options passed to your application.
args:
- production
hosts:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
- www.PROJECTNAME.com
# Static files.
- type: static-files
hosts:
- static.PROJECTNAME.com
root: ../static
# Uncomment to turn on directory listings.
# directory-listing: true
# Redirect plain domain name to www.
- type: redirect
hosts:
- PROJECTNAME.com
actions:
- host: www.PROJECTNAME.com
# secure: false
# port: 80
# Uncomment to switch to a non-permanent redirect.
# status: 303
# Use the following to automatically copy your bundle upon creation via `yesod
# keter`. Uses `scp` internally, so you can set it to a remote destination
# copy-to: user@host:/opt/keter/incoming
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
# postgres: true
{-# START_FILE config/robots.txt #-}
User-agent: *

View File

@ -711,15 +711,63 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
{-# START_FILE config/keter.yml #-}
exec: ../dist/build/PROJECTNAME/PROJECTNAME
args:
- production
host: <<HOST-NOT-SET>>
# After you've edited this file, remove the following line to allow
# `yesod keter` to build your bundle.
user-edited: false
# A Keter app is composed of 1 or more stanzas. The main stanza will define our
# web application. See the Keter documentation for more information on
# available stanzas.
stanzas:
# Your Yesod application.
- type: webapp
# Name of your executable. You are unlikely to need to change this.
# Note that all file paths are relative to the keter.yml file.
exec: ../dist/build/PROJECTNAME/PROJECTNAME
# Command line options passed to your application.
args:
- production
hosts:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
- www.PROJECTNAME.com
# Static files.
- type: static-files
hosts:
- static.PROJECTNAME.com
root: ../static
# Uncomment to turn on directory listings.
# directory-listing: true
# Redirect plain domain name to www.
- type: redirect
hosts:
- PROJECTNAME.com
actions:
- host: www.PROJECTNAME.com
# secure: false
# port: 80
# Uncomment to switch to a non-permanent redirect.
# status: 303
# Use the following to automatically copy your bundle upon creation via `yesod
# keter`. Uses `scp` internally, so you can set it to a remote destination
# copy-to: user@host:/opt/keter/incoming
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
# postgres: true
{-# START_FILE config/models #-}
User
ident Text