summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2017-01-22 17:37:35 +0100
committerSimon Jakobi <simon.jakobi@gmail.com>2017-01-22 18:08:25 +0100
commite46adb860c2548db519940a36768482d7b49f0ef (patch)
tree2636730fcda114f6c10646fa309e4bf45000ad71
parentd0ebefba0e415b2fb1326243b2cd658041f6eb9d (diff)
downloadhakyll-e46adb860c2548db519940a36768482d7b49f0ef.tar.gz
Move hakyll-init to https://github.com/jaspervdj/hakyll-init
-rw-r--r--hakyll.cabal14
-rw-r--r--src/Hakyll/Init.hs96
2 files changed, 0 insertions, 110 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 8a13e9c..9d60f1a 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -308,17 +308,3 @@ Test-suite hakyll-tests
http-types >= 0.7 && < 0.10
Cpp-options:
-DCHECK_EXTERNAL
-
-Executable hakyll-init
- Ghc-options: -Wall
- Hs-source-dirs: src
- Main-is: Hakyll/Init.hs
-
- Build-depends:
- base >= 4 && < 5,
- directory >= 1.0 && < 1.4,
- filepath >= 1.0 && < 1.5
-
- Other-modules:
- Hakyll.Core.Util.File
- Paths_hakyll
diff --git a/src/Hakyll/Init.hs b/src/Hakyll/Init.hs
deleted file mode 100644
index 71055f0..0000000
--- a/src/Hakyll/Init.hs
+++ /dev/null
@@ -1,96 +0,0 @@
---------------------------------------------------------------------------------
-module Main
- ( main
- ) where
-
-
---------------------------------------------------------------------------------
-import Control.Arrow (first)
-import Control.Monad (forM_)
-import Data.Char (isAlphaNum, isNumber)
-import Data.List (foldl')
-import Data.List (intercalate, isPrefixOf)
-import Data.Version (Version (..))
-import System.Directory (canonicalizePath, copyFile)
-import System.Environment (getArgs, getProgName)
-import System.Exit (exitFailure)
-import System.FilePath (splitDirectories, (</>))
-
-
---------------------------------------------------------------------------------
-import Hakyll.Core.Util.File
-import Paths_hakyll
-
-
---------------------------------------------------------------------------------
-main :: IO ()
-main = do
- progName <- getProgName
- args <- getArgs
- srcDir <- getDataFileName "example"
- files <- getRecursiveContents (const $ return False) srcDir
-
- case args of
- -- When the argument begins with hyphens, it's more likely that the user
- -- intends to attempt some arguments like ("--help", "-h", "--version", etc.)
- -- rather than create directory with that name.
- -- If dstDir begins with hyphens, the guard will prevent it from creating
- -- directory with that name so we can fall to the second alternative
- -- which prints a usage info for user.
- [dstDir] | not ("-" `isPrefixOf` dstDir) -> do
- forM_ files $ \file -> do
- let dst = dstDir </> file
- src = srcDir </> file
- putStrLn $ "Creating " ++ dst
- makeDirectories dst
- copyFile src dst
-
- name <- makeName dstDir
- let cabalPath = dstDir </> name ++ ".cabal"
- putStrLn $ "Creating " ++ cabalPath
- createCabal cabalPath name
- _ -> do
- putStrLn $ "Usage: " ++ progName ++ " <directory>"
- exitFailure
-
--- | Figure out a good cabal package name from the given (existing) directory
--- name
-makeName :: FilePath -> IO String
-makeName dstDir = do
- canonical <- canonicalizePath dstDir
- return $ case safeLast (splitDirectories canonical) of
- Nothing -> fallbackName
- Just "/" -> fallbackName
- Just x -> repair (fallbackName ++) id x
- where
- -- Package name repair code comes from
- -- cabal-install.Distribution.Client.Init.Heuristics
- repair invalid valid x = case dropWhile (not . isAlphaNum) x of
- "" -> repairComponent ""
- x' -> let (c, r) = first repairComponent $ break (not . isAlphaNum) x'
- in c ++ repairRest r
- where repairComponent c | all isNumber c = invalid c
- | otherwise = valid c
- repairRest = repair id ('-' :)
- fallbackName = "site"
-
- safeLast = foldl' (\_ x -> Just x) Nothing
-
-createCabal :: FilePath -> String -> IO ()
-createCabal path name = do
- writeFile path $ unlines [
- "name: " ++ name
- , "version: 0.1.0.0"
- , "build-type: Simple"
- , "cabal-version: >= 1.10"
- , ""
- , "executable site"
- , " main-is: site.hs"
- , " build-depends: base == 4.*"
- , " , hakyll == " ++ version' ++ ".*"
- , " ghc-options: -threaded"
- , " default-language: Haskell2010"
- ]
- where
- -- Major hakyll version
- version' = intercalate "." . take 2 . map show $ versionBranch version