foliage/app/Foliage/Shake.hs
Andrea Bedini 9a4d097cde Rework internals and add consistency check
The function preparePackageVersion is now responsible for doing
everything we need to do to be able to include the package in the index.

The function also returns a denormalised view of the package information
which can be taken as a proof that everything is consistent.
2023-03-03 08:15:19 +08:00

40 lines
1.1 KiB
Haskell

module Foliage.Shake
( computeFileInfoSimple',
readKeysAt,
readPackageVersionSpec',
readGenericPackageDescription',
)
where
import Data.Traversable (for)
import Development.Shake
import Development.Shake.FilePath
import Distribution.Simple.PackageDescription
import Distribution.Types.GenericPackageDescription
import Distribution.Verbosity qualified as Verbosity
import Foliage.HackageSecurity
import Foliage.Meta
computeFileInfoSimple' :: FilePath -> Action FileInfo
computeFileInfoSimple' fp = do
need [fp]
liftIO $ computeFileInfoSimple fp
readKeysAt :: FilePath -> Action [Some Key]
readKeysAt base = do
paths <- getDirectoryFiles base ["*.json"]
need $ map (base </>) paths
for paths $ \path -> do
Right key <- liftIO $ readJSONSimple (base </> path)
pure key
readPackageVersionSpec' :: FilePath -> Action PackageVersionSpec
readPackageVersionSpec' fp = do
need [fp]
liftIO $ readPackageVersionSpec fp
readGenericPackageDescription' :: FilePath -> Action GenericPackageDescription
readGenericPackageDescription' fp = do
need [fp]
liftIO $ readGenericPackageDescription Verbosity.silent fp