summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorstuebinm2021-11-10 22:49:17 +0100
committerstuebinm2021-11-10 22:49:17 +0100
commit508f8885f6087f2c56b188cd0632a4fc39de0540 (patch)
tree95c8036e1d73ee2a0b20ef76d892d83927fd6243 /lib
parent5bb4079f7b2d576f67649c37874556e73dc8f68b (diff)
extra module for repository writeout
Diffstat (limited to 'lib')
-rw-r--r--lib/CheckDir.hs13
-rw-r--r--lib/CheckMap.hs2
-rw-r--r--lib/WriteRepo.hs28
3 files changed, 33 insertions, 10 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