packages feed

zifter-stack 0.0.0.5 → 0.0.0.6

raw patch · 2 files changed

+63/−3 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Zifter.Stack: combine :: Ord a => [(a, b)] -> [(a, [b])]
+ Zifter.Stack: hidden :: Path Abs t -> Bool
+ Zifter.Stack: stackGetPackageTargetTuplesAccordingToCabalFiles :: Zift [(String, [String])]
+ Zifter.Stack: stackGetPackageTargetTuplesAccordingToStackIDE :: Zift [(String, [String])]
+ Zifter.Stack: uncombine :: Ord a => [(a, [b])] -> [(a, b)]

Files

src/Zifter/Stack.hs view
@@ -2,12 +2,24 @@  import Control.Monad import Control.Monad.IO.Class-import Data.List (isPrefixOf)+import Data.Function (on)+import Data.List+       (groupBy, intersect, isInfixOf, isPrefixOf, sortOn)+import Data.Maybe (mapMaybe) import Path+import Path.IO+import Safe import System.Exit (ExitCode(..))+import qualified System.FilePath as FP (splitPath) import System.IO import System.Process +import Distribution.Package+import Distribution.PackageDescription+import Distribution.PackageDescription.Configuration+import Distribution.PackageDescription.Parse+import Distribution.Verbosity+ import Zifter.Zift  stackBuildZift :: Zift ()@@ -33,6 +45,23 @@  stackGetPackageTargetTuples :: Zift [(String, [String])] stackGetPackageTargetTuples = do+    sps <- stackGetPackageTargetTuplesAccordingToStackIDE+    cps <- stackGetPackageTargetTuplesAccordingToCabalFiles+    pure $ combine $ uncombine sps `intersect` uncombine cps++combine :: Ord a => [(a, b)] -> [(a, [b])]+combine =+    mapMaybe (\tups -> (,) <$> (fst <$> headMay tups) <*> pure (map snd tups)) .+    groupBy ((==) `on` fst) . sortOn fst++uncombine :: Ord a => [(a, [b])] -> [(a, b)]+uncombine xs = do+    (a, bs) <- xs+    b <- bs+    pure (a, b)++stackGetPackageTargetTuplesAccordingToStackIDE :: Zift [(String, [String])]+stackGetPackageTargetTuplesAccordingToStackIDE = do     rd <- getRootDir     let getErrFrom cmd = do             (_, _, merrh, ph) <-@@ -55,6 +84,29 @@     let packages = lines outp     pure $ flip map packages $ \t -> (t, filter (isPrefixOf t) targets) +stackGetPackageTargetTuplesAccordingToCabalFiles :: Zift [(String, [String])]+stackGetPackageTargetTuplesAccordingToCabalFiles = do+    rd <- getRootDir+    (_, fs) <- liftIO $ listDirRecur rd+    let cabalFiles =+            filter (not . isInfixOf ".stack-work" . toFilePath) $+            filter (not . hidden) $ filter ((== ".cabal") . fileExtension) fs+    (concat <$>) $+        forM cabalFiles $ \cabalFile -> do+            pd <-+                liftIO $ readPackageDescription deafening $ toFilePath cabalFile+            let packageDesc = flattenPackageDescription pd+                name = unPackageName $ pkgName $ package packageDesc+                libname = name ++ ":lib"+                lib =+                    case library packageDesc of+                        Nothing -> []+                        Just _ -> [libname]+                testnames =+                    map (((name ++ ":test:") ++) . testName) $+                    testSuites packageDesc+            pure [(name, lib ++ testnames)]+ stackBuild :: Zift () stackBuild = do     rd <- getRootDir@@ -86,4 +138,12 @@     forM_ tups $ \(package_, targets) -> do         stack $ unwords ["clean", package_]         forM_ targets $ \target ->-            stack $ unwords ["build --pedantic --haddock --test", target]+            stack $+            unwords+                [ "build --pedantic --haddock --test"+                , target+                , "--test-arguments='--fail-fast --seed=42'"+                ]++hidden :: Path Abs t -> Bool+hidden = any ((Just '.' ==) . headMay) . FP.splitPath . toFilePath
zifter-stack.cabal view
@@ -1,5 +1,5 @@ name: zifter-stack-version: 0.0.0.5+version: 0.0.0.6 cabal-version: >=1.10 build-type: Simple license: MIT