codex 0.4.0.10 → 0.5.0.0
raw patch · 10 files changed
+95/−29 lines, 10 filesdep ~codex
Dependency ranges changed: codex
Files
- codex.cabal +3/−2
- codex/Main.hs +7/−4
- codex/Main/Config.hs +14/−8
- codex/Main/Config/Codex0.hs +1/−1
- codex/Main/Config/Codex1.hs +8/−1
- codex/Main/Config/Codex2.hs +8/−1
- codex/Main/Config/Codex3.hs +34/−0
- src/Codex.hs +1/−1
- src/Codex/Internal.hs +16/−8
- src/Codex/Project.hs +3/−3
codex.cabal view
@@ -1,5 +1,5 @@ name: codex-version: 0.4.0.10+version: 0.5.0.0 synopsis: A ctags file generator for cabal project dependencies. description: This tool download and cache the source code of packages in your local hackage,@@ -61,6 +61,7 @@ Main.Config.Codex0 Main.Config.Codex1 Main.Config.Codex2+ Main.Config.Codex3 Paths_codex build-depends: base@@ -77,7 +78,7 @@ , transformers , wreq , yaml - , codex == 0.4.0.10+ , codex == 0.5.0.0 source-repository head type: git
codex/Main.hs view
@@ -98,6 +98,7 @@ where ignore msg = do putStrLn $ concat ["codex: *warning* unable to fetch an archive for ", display i]+ putStrLn msg return () help :: IO ()@@ -142,10 +143,12 @@ (ec, _, _) <- readCreateProcessWithExitCode (shell "which stack") "" case ec of ExitSuccess -> do- globalPath <- readStackPath "global-stack-root"- binPath <- readStackPath "bin-path"- setEnv "PATH" binPath- return (Stack, cx' { hackagePath = globalPath </> "indices" </> "Hackage" })+ let opts = stackOpts cx'+ globalPath <- readStackPath opts "stack-root"+ binPath <- readStackPath opts "bin-path"+ path <- getEnv "PATH"+ setEnv "PATH" $ concat [path, ":", binPath]+ return (Stack opts, cx' { hackagePath = globalPath </> "indices" </> "Hackage" }) _ -> return (Cabal, cx') else return (Cabal, cx')
codex/Main/Config.hs view
@@ -9,6 +9,7 @@ import qualified Main.Config.Codex0 as C0 import qualified Main.Config.Codex1 as C1 import qualified Main.Config.Codex2 as C2+import qualified Main.Config.Codex3 as C3 import qualified Distribution.Hackage.DB as DB data ConfigState = Ready | TaggerNotFound@@ -31,7 +32,7 @@ loadConfig = decodeConfig >>= maybe defaultConfig return where defaultConfig = do hp <- DB.hackagePath- let cx = Codex True (dropFileName hp) (taggerCmd Hasktags) True True defaultTagsFileName+ let cx = Codex True (dropFileName hp) defaultStackOpts (taggerCmd Hasktags) True True defaultTagsFileName encodeConfig cx return cx @@ -46,14 +47,18 @@ cfg <- config path case cfg of Nothing -> do- cfg2 <- config2 path- case cfg2 of+ cfg3 <- config3 path+ case cfg3 of Nothing -> do- cfg1 <- config1 path- case cfg1 of- Nothing -> config0 path- cfg1' -> return cfg1'- cfg2' -> return cfg2'+ cfg2 <- config2 path+ case cfg2 of+ Nothing -> do+ cfg1 <- config1 path+ case cfg1 of+ Nothing -> config0 path+ cfg1' -> return cfg1'+ cfg2' -> return cfg2'+ cfg3' -> return cfg3' cfg' -> return cfg' where warn :: IO () -> IO ()@@ -65,6 +70,7 @@ config0 = reencodeConfigOf C0.migrate C0.migrateWarn config1 = reencodeConfigOf C1.migrate C1.migrateWarn config2 = reencodeConfigOf C2.migrate C2.migrateWarn+ config3 = reencodeConfigOf C3.migrate C3.migrateWarn reencodeConfigOf migrate migrateWarn path = do rawCfg <- configOf path
codex/Main/Config/Codex0.hs view
@@ -16,4 +16,4 @@ migrateWarn = return () migrate :: Codex -> New.Codex-migrate cx = New.Codex True (hackagePath cx) (tagsCmd cx) True True New.defaultTagsFileName+migrate cx = New.Codex True (hackagePath cx) New.defaultStackOpts (tagsCmd cx) True True New.defaultTagsFileName
codex/Main/Config/Codex1.hs view
@@ -18,4 +18,11 @@ putStrLn "\tif that is not the behavior you want, please edit `~/.codex`." migrate :: Codex -> New.Codex-migrate cx = New.Codex True (hackagePath cx) (tagsCmd cx) (tagsFileHeader cx) (tagsFileSorted cx) New.defaultTagsFileName+migrate cx = New.Codex+ True+ (hackagePath cx)+ New.defaultStackOpts+ (tagsCmd cx)+ (tagsFileHeader cx)+ (tagsFileSorted cx)+ New.defaultTagsFileName
codex/Main/Config/Codex2.hs view
@@ -17,4 +17,11 @@ migrate :: Codex -> New.Codex migrate cx =- New.Codex True (hackagePath cx) (tagsCmd cx) (tagsFileHeader cx) (tagsFileSorted cx) New.defaultTagsFileName+ New.Codex+ True+ (hackagePath cx)+ New.defaultStackOpts+ (tagsCmd cx)+ (tagsFileHeader cx)+ (tagsFileSorted cx)+ New.defaultTagsFileName
+ codex/Main/Config/Codex3.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE DeriveGeneric #-}+module Main.Config.Codex3 where++import Data.Yaml+import GHC.Generics++import qualified Codex as New++data Codex = Codex+ { currentProjectIncluded :: Bool+ , hackagePath :: FilePath+ , tagsCmd :: String+ , tagsFileHeader :: Bool+ , tagsFileSorted :: Bool+ , tagsFileName :: FilePath }+ deriving Generic++instance ToJSON Codex+instance FromJSON Codex++migrateWarn :: IO ()+migrateWarn = return ()++migrate :: Codex -> New.Codex+migrate cx =+ New.Codex+ True+ (hackagePath cx)+ (New.defaultStackOpts)+ (tagsCmd cx)+ (tagsFileHeader cx)+ (tagsFileSorted cx)+ (tagsFileName cx)+
src/Codex.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-}-module Codex (Codex(..), defaultTagsFileName, Verbosity, module Codex) where+module Codex (Codex(..), defaultStackOpts, defaultTagsFileName, Verbosity, module Codex) where #if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))
src/Codex/Internal.hs view
@@ -18,14 +18,18 @@ import qualified Data.List as L +defaultStackOpts :: FilePath+defaultStackOpts = ""+ defaultTagsFileName :: FilePath defaultTagsFileName = "codex.tags" -data Builder = Cabal | Stack+data Builder = Cabal | Stack String data Codex = Codex { currentProjectIncluded :: Bool , hackagePath :: FilePath+ , stackOpts :: String , tagsCmd :: String , tagsFileHeader :: Bool , tagsFileSorted :: Bool@@ -37,8 +41,8 @@ instance FromJSON Codex hackagePathOf :: Builder -> Codex -> FilePath-hackagePathOf Cabal cx = hackagePath cx-hackagePathOf Stack cx = hackagePath cx </> "packages"+hackagePathOf Cabal cx = hackagePath cx+hackagePathOf (Stack _) cx = hackagePath cx </> "packages" packagePath :: FilePath -> PackageIdentifier -> FilePath packagePath root i = root </> relativePath i where@@ -70,12 +74,16 @@ where trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace -readStackPath :: String -> IO String-readStackPath id' = init <$> readCreateProcess (shell ("stack path --" ++ id')) ""+readStackPath :: String -> String -> IO String+readStackPath opts id' = do+ let cmd = concat ["stack ", opts, " path --", id']+ s <- readCreateProcess (shell cmd) ""+ return $ init s -stackListDependencies :: IO [PackageIdentifier]-stackListDependencies = do- s <- readCreateProcess (shell ("stack list-dependencies")) ""+stackListDependencies :: String -> IO [PackageIdentifier]+stackListDependencies opts = do+ let cmd = concat ["stack ", opts, " list-dependencies"]+ s <- readCreateProcess (shell cmd) "" return $ mapMaybe parsePackageIdentifier $ lines s where parsePackageIdentifier line =
src/Codex/Project.hs view
@@ -85,8 +85,8 @@ xs = fmap sourcePackageId $ ys return xs where withCabal = getPersistBuildConfig $ root </> "dist"- Stack -> let self = package (packageDescription pd)- in filter (/=self) <$> stackListDependencies+ Stack cmd -> let self = package (packageDescription pd)+ in filter (/=self) <$> stackListDependencies cmd resolveHackageDependencies :: Hackage -> GenericPackageDescription -> [GenericPackageDescription] resolveHackageDependencies db pd = maybeToList . resolveDependency db =<< allDependencies pd where@@ -100,7 +100,7 @@ xs <- either fallback return =<< resolveInstalledDependencies bldr root pd return xs where fallback e = do- putStrLn $ concat ["cabal: ", show e]+ putStrLn $ concat ["codex: ", show e] putStrLn "codex: *warning* falling back on dependency resolution using hackage" resolveWithHackage resolveWithHackage = do