Skip to content

Commit

Permalink
Install on need verify package (#94)
Browse files Browse the repository at this point in the history
* read and write add-from-bower from local package set

* make add-from-bower write to local package set

updates lts to use newer aeson-pretty to use trailing newline formatting

* make add-from-bower write to local package set

also adds a newer aeson-pretty to extra-deps to use trailing newline
formatting

* have verify pull dependencies per verifying package

as the installation step checks to not reinstall existing packages,
calling it multiple times with previously installed packages works fine.

* concurrently traverse the dependencies for verify
  • Loading branch information
justinwoo authored Mar 19, 2018
1 parent cda2f05 commit cffedc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
module Main where

import qualified Control.Foldl as Foldl
import Control.Concurrent.Async (forConcurrently_)
import Control.Concurrent.Async (forConcurrently_, mapConcurrently)
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (fieldLabelModifier)
import Data.Aeson.Encode.Pretty
Expand Down Expand Up @@ -474,17 +474,19 @@ verify arg = do
verifyPackages names db pkg = do
echoT $ "Verifying " <> pack (show $ length names) <> " packages."
echoT "Warning: this could take some time!"

let go (name_, pkgInfo) = (name_, ) <$> performInstall (set pkg) name_ pkgInfo
paths <- Map.fromList <$> traverse go (Map.toList db)
traverse_ (verifyPackage db paths) names

verifyPackage :: PackageSet -> Map.Map PackageName Turtle.FilePath -> PackageName -> IO ()
verifyPackage db paths name = do
let dirFor pkgName = fromMaybe (error ("verifyPackageSet: no directory for " <> show pkgName)) (Map.lookup pkgName paths)
traverse_ (verifyPackage db pkg) names

verifyPackage :: PackageSet -> PackageConfig -> PackageName -> IO ()
verifyPackage db pkg name = do
let
dirFor pkgName =
case Map.lookup pkgName db of
Nothing -> error ("verifyPackageSet: no directory for " <> show pkgName)
Just pkgInfo -> performInstall (set pkg) pkgName pkgInfo
echoT ("Verifying package " <> runPackageName name)
dependencies <- map fst <$> getTransitiveDeps db [name]
let srcGlobs = map (pathToTextUnsafe . (</> ("src" </> "**" </> "*.purs")) . dirFor) dependencies
dirs <- mapConcurrently dirFor dependencies
let srcGlobs = map (pathToTextUnsafe . (</> ("src" </> "**" </> "*.purs"))) dirs
procs "purs" ("compile" : srcGlobs) empty

data BowerInfoRepo = BowerInfoRepo
Expand Down
3 changes: 2 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resolver: lts-11.1
packages:
- '.'
extra-deps: []
extra-deps:
- aeson-pretty-0.8.5 # newer in lts-11.1 needed for formatting packages.json

0 comments on commit cffedc6

Please sign in to comment.