@@ -3,6 +3,7 @@ module Setup.BuildPlan (constructBuildPlan, BuildPlan) where
33import Prelude
44
55import Actions.Core as Core
6+ import Data.Argonaut.Core (Json )
67import Data.Argonaut.Decode (decodeJson , printJsonDecodeError , (.:))
78import Data.Array as Array
89import Data.Bifunctor (bimap , lmap )
@@ -18,16 +19,15 @@ import Setup.Data.Key (Key)
1819import Setup.Data.Key as Key
1920import Setup.Data.Tool (Tool , required )
2021import Setup.Data.Tool as Tool
21- import Setup.Data.VersionsFile (readVersionsFile )
2222import Text.Parsing.Parser (parseErrorMessage )
2323import Text.Parsing.Parser as ParseError
2424
2525-- | The list of tools that should be downloaded and cached by the action
2626type BuildPlan = Array { tool :: Tool , version :: Version }
2727
2828-- | Construct the list of tools that sholud be downloaded and cached by the action
29- constructBuildPlan :: Effect BuildPlan
30- constructBuildPlan = map Array .catMaybes $ traverse resolve Tool .allTools
29+ constructBuildPlan :: Json -> Effect BuildPlan
30+ constructBuildPlan json = map Array .catMaybes $ traverse ( resolve json) Tool .allTools
3131
3232-- | The parsed value of an input field that specifies a version
3333data VersionField = Latest | Exact Version
@@ -42,8 +42,8 @@ getVersionField = map (map parse) <<< Core.getInput
4242
4343-- | Resolve the exact version to provide for a tool in the environment, based
4444-- | on the action.yml file.
45- resolve :: Tool -> Effect (Maybe { tool :: Tool , version :: Version } )
46- resolve tool = do
45+ resolve :: Json -> Tool -> Effect (Maybe { tool :: Tool , version :: Version } )
46+ resolve versionsContents tool = do
4747 let key = Key .fromTool tool
4848 getVersionField key >>= case _ of
4949 Nothing | required tool -> throwError $ error " No input received for required key."
@@ -63,10 +63,9 @@ resolve tool = do
6363
6464 Right Latest -> do
6565 Core .info $ fold [ " Fetching latest tag for " , Tool .name tool ]
66- json <- readVersionsFile
6766
6867 let
69- version = lmap printJsonDecodeError $ (_ .: Tool .name tool) =<< decodeJson json
68+ version = lmap printJsonDecodeError $ (_ .: Tool .name tool) =<< decodeJson versionsContents
7069 parse = lmap parseErrorMessage <<< Version .parseVersion
7170
7271 case parse =<< version of
0 commit comments