summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CheckDir.hs13
-rw-r--r--lib/CheckMap.hs2
-rw-r--r--lib/WriteRepo.hs28
-rw-r--r--src/Main.hs4
-rw-r--r--walint.cabal1
5 files changed, 36 insertions, 12 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs
index 4654051..68bcefe 100644
--- a/lib/CheckDir.hs
+++ b/lib/CheckDir.hs
@@ -6,17 +6,17 @@
{-# LANGUAGE TupleSections #-}
-- | Module that contains high-level checking for an entire directory
-module CheckDir (recursiveCheckDir, writeAdjustedRepository) where
+module CheckDir (recursiveCheckDir, DirResult(..)) where
-import CheckMap (MapResult (mapresultAdjusted, mapresultProvides),
+import CheckMap (MapResult (mapresultProvides),
loadAndLintMap, mapresultDepends)
import Control.Monad (void)
import Control.Monad.Extra (mapMaybeM)
-import Data.Aeson (ToJSON, encodeFile, (.=))
+import Data.Aeson (ToJSON, (.=))
import qualified Data.Aeson as A
import Data.Foldable (fold)
import Data.Functor ((<&>))
-import Data.Map (Map, toList)
+import Data.Map (Map)
import qualified Data.Map as M
import Data.Map.Strict (mapKeys, (\\))
import Data.Maybe (mapMaybe)
@@ -206,8 +206,3 @@ recursiveCheckDir' prefix paths done acc = do
-writeAdjustedRepository :: FilePath -> DirResult -> IO ()
-writeAdjustedRepository outPath result =
- mapM_
- (\(path,out) -> encodeFile (outPath </> path) $ mapresultAdjusted out)
- (toList $ dirresultMaps result)
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 41f251e..1b42854 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -11,6 +11,7 @@ module CheckMap (loadAndLintMap, MapResult(..)) where
import Data.Aeson (ToJSON (toJSON))
import qualified Data.Aeson as A
import Data.Aeson.Types ((.=))
+import Data.Functor ((<&>))
import Data.Map (Map, toList)
import qualified Data.Map as M
import Data.Maybe (mapMaybe)
@@ -20,7 +21,6 @@ import qualified Data.Vector as V
import GHC.Generics (Generic)
-import Data.Functor ((<&>))
import LintWriter (filterLintLevel, invertLintResult, lintToDep,
resultToAdjusted, resultToDeps,
resultToLints, resultToOffers, runLintWriter)
diff --git a/lib/WriteRepo.hs b/lib/WriteRepo.hs
new file mode 100644
index 0000000..5e695f5
--- /dev/null
+++ b/lib/WriteRepo.hs
@@ -0,0 +1,28 @@
+
+
+
+-- | Module for writing an already linted map Repository back out again.
+
+module WriteRepo where
+
+import CheckDir (DirResult (dirresultMaps))
+import CheckMap (MapResult (mapresultAdjusted))
+import Data.Aeson (encodeFile)
+import Data.Map.Strict (toList)
+import System.Directory.Extra (createDirectoryIfMissing)
+import System.FilePath.Posix ((</>))
+
+
+
+writeAdjustedRepository :: FilePath -> DirResult -> IO ()
+writeAdjustedRepository outPath result = do
+
+ -- True here just means the equivalent of mkdir -p
+ createDirectoryIfMissing True outPath
+
+ -- write out all maps
+ mapM_
+ (\(path,out) -> encodeFile (outPath </> path) $ mapresultAdjusted out)
+ (toList $ dirresultMaps result)
+
+ -- TODO: copy all assets
diff --git a/src/Main.hs b/src/Main.hs
index 0e80eab..8cbfe7d 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -13,8 +13,8 @@ import qualified Data.ByteString.Lazy as LB
import Data.Maybe (fromMaybe)
import WithCli
-import CheckDir (recursiveCheckDir,
- writeAdjustedRepository)
+import CheckDir (recursiveCheckDir)
+import WriteRepo (writeAdjustedRepository)
import Types (Level (..))
import Util (printPretty)
diff --git a/walint.cabal b/walint.cabal
index fcb631b..069d8f3 100644
--- a/walint.cabal
+++ b/walint.cabal
@@ -27,6 +27,7 @@ library
hs-source-dirs: lib
exposed-modules:
CheckMap
+ WriteRepo
CheckDir
LintWriter
Properties