Skip to content

Commit

Permalink
Use multiple top-level values for BuildInfo.purs (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMartinez authored Dec 4, 2023
1 parent e0013d6 commit 954f331
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ jobs:
- name: Build the project
run: spago build

- name: Bootstrap executable
run: node ./bin/index.dev.js bundle -p spago-bin
# - name: Bootstrap executable
# run: node ./bin/index.dev.js bundle -p spago-bin

- name: Bundle docs-search client
run: node ./bin/bundle.js bundle -p docs-search-client-halogen
# - name: Bundle docs-search client
# run: node ./bin/bundle.js bundle -p docs-search-client-halogen

- name: Run tests
run: node ./bin/bundle.js test
# - name: Run tests
# run: node ./bin/bundle.js test

- name: Check formatting (Linux only)
if: matrix.os == 'ubuntu-latest'
Expand Down
19 changes: 12 additions & 7 deletions src/Spago/BuildInfo.purs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ writeBuildInfo = do
-- TODO: use tidy-codegen eventually
mkBuildInfo :: BuildInfo -> String
mkBuildInfo { packages, pursVersion } = String.joinWith "\n"
[ "-- @inline export buildInfo always"
[ "-- @inline export packages always"
, "-- @inline export pursVersion always"
, "-- @inline export spagoVersion always"
, "module Spago.Generated.BuildInfo where"
, ""
, "buildInfo :: { packages :: " <> recordType <> ", pursVersion :: String, spagoVersion :: String }"
, "buildInfo ="
, " { packages: {" <> String.joinWith ", " (map renderPackage packages) <> "}"
, " , pursVersion: \"" <> pursVersion <> "\""
, " , spagoVersion: \"" <> currentSpagoVersion <> "\""
, " }"
, "packages :: " <> recordType
, "packages = "
, " { " <> String.joinWith "\n , " (map renderPackage packages) <> "\n }"
, ""
, "pursVersion :: String"
, "pursVersion = \"" <> pursVersion <> "\""
, ""
, "spagoVersion :: String"
, "spagoVersion = \"" <> currentSpagoVersion <> "\""
, ""
]
where
Expand Down
6 changes: 3 additions & 3 deletions test/Spago/Build/BuildInfo.purs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ spec =
, ""
, "main :: Effect Unit"
, "main = do"
, " Console.log $ \"pursVersion: \" <> BI.buildInfo.pursVersion"
, " Console.log $ \"spagoVersion: \" <> BI.buildInfo.spagoVersion"
, " Console.log $ \"pursVersion: \" <> BI.pursVersion"
, " Console.log $ \"spagoVersion: \" <> BI.spagoVersion"
]
<> -- ensure all packages within the workspace are reference-able
( packages <#> \packageName ->
" Console.log $ \"" <> packageName <> ": \" <> BI.buildInfo.packages." <> packageName
" Console.log $ \"" <> packageName <> ": \" <> BI.packages." <> packageName
)

Spec.describe "using generated 'BuildInfo.purs' file in single-package context" do
Expand Down

0 comments on commit 954f331

Please sign in to comment.