2022-03-28 07:53:39 +03:00
|
|
|
module Foliage.Shake
|
|
|
|
( computeFileInfoSimple',
|
|
|
|
readFileByteStringLazy,
|
|
|
|
readKeysAt,
|
2022-05-19 09:42:41 +03:00
|
|
|
readPackageVersionMeta',
|
2022-03-28 07:53:39 +03:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Data.ByteString.Lazy qualified as BSL
|
|
|
|
import Data.Traversable (for)
|
|
|
|
import Development.Shake
|
|
|
|
import Development.Shake.FilePath
|
|
|
|
import Foliage.HackageSecurity
|
|
|
|
import Foliage.Meta
|
|
|
|
|
|
|
|
computeFileInfoSimple' :: FilePath -> Action FileInfo
|
|
|
|
computeFileInfoSimple' fp = do
|
2022-05-26 05:55:30 +03:00
|
|
|
need [fp]
|
|
|
|
liftIO $ computeFileInfoSimple fp
|
2022-03-28 07:53:39 +03:00
|
|
|
|
|
|
|
readFileByteStringLazy :: FilePath -> Action BSL.ByteString
|
|
|
|
readFileByteStringLazy x = need [x] >> liftIO (BSL.readFile x)
|
|
|
|
|
|
|
|
readKeysAt :: FilePath -> Action [Some Key]
|
|
|
|
readKeysAt base = do
|
2022-03-30 07:32:49 +03:00
|
|
|
paths <- getDirectoryFiles base ["*.json"]
|
2022-03-28 07:53:39 +03:00
|
|
|
need $ map (base </>) paths
|
|
|
|
for paths $ \path -> do
|
|
|
|
Right key <- liftIO $ readJSONSimple (base </> path)
|
|
|
|
pure key
|
|
|
|
|
2022-05-19 09:42:41 +03:00
|
|
|
readPackageVersionMeta' :: FilePath -> Action PackageVersionMeta
|
|
|
|
readPackageVersionMeta' fp = do
|
2022-03-28 07:53:39 +03:00
|
|
|
need [fp]
|
2022-05-19 09:42:41 +03:00
|
|
|
liftIO $ readPackageVersionMeta fp
|