Skip to content

Commit b6b317c

Browse files
Fetch versions file remotely.
1 parent 980da9f commit b6b317c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/update.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Main.purs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ module Main where
22

33
import Prelude
44

5+
import Affjax (printError)
6+
import Affjax as AX
7+
import Affjax.ResponseFormat as RF
58
import Control.Monad.Except.Trans (ExceptT(..), mapExceptT, runExceptT)
6-
import Data.Argonaut.Parser as Json
79
import Data.Bifunctor (lmap)
810
import Data.Either (Either(..))
911
import Data.Foldable (traverse_)
@@ -12,22 +14,20 @@ import Effect.Aff (error, launchAff_, runAff_)
1214
import Effect.Class (liftEffect)
1315
import Effect.Exception (message)
1416
import GitHub.Actions.Core as Core
15-
import Node.Buffer as Buffer
16-
import Node.Encoding (Encoding(..))
17-
import Node.FS.Sync (readFile)
1817
import Setup.BuildPlan (constructBuildPlan)
1918
import Setup.GetTool (getTool)
2019
import Setup.UpdateVersions (updateVersions)
2120

2221
main :: Effect Unit
2322
main = runAff_ go $ runExceptT do
24-
versionsString <- liftEffect $ Buffer.toString UTF8 =<< readFile "./dist/versions.json"
25-
versionsJson <- ExceptT $ pure $ lmap error $ Json.jsonParser versionsString
26-
tools <- mapExceptT liftEffect $ constructBuildPlan versionsJson
23+
versionsJson <- ExceptT $ map (lmap (error <<< printError)) $ AX.get RF.json versionsFile
24+
tools <- mapExceptT liftEffect $ constructBuildPlan versionsJson.body
2725
liftEffect $ Core.info "Constructed build plan."
2826
traverse_ getTool tools
2927
liftEffect $ Core.info "Fetched tools."
3028
where
29+
versionsFile = "https://raw.githubusercontent.com/purescript-contrib/setup-purescript/main/dist/versions.json"
30+
3131
go res = case join res of
3232
Left err -> Core.setFailed (message err)
3333
Right a -> pure unit

0 commit comments

Comments
 (0)