Skip to content

Commit

Permalink
Properly track Env config usage in RPC.elm as well
Browse files Browse the repository at this point in the history
  • Loading branch information
supermario committed Oct 27, 2024
1 parent b2146db commit aeda61f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions extra/Lamdera/AppConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ writeUsage = do
& writeUtf8 (cache </> ".lamdera-fe-config")

findSecretUses graph "Backend" "app"
& Set.union (findSecretUses graph "RPC" "lamdera_handleEndpoints")
& prep
& writeUtf8 (cache </> ".lamdera-be-config")


loadLamderaAppGraph :: IO GlobalGraph
loadLamderaAppGraph = do
graph_ <- Lamdera.Graph.fullGraph ["src/Frontend.elm", "src/Backend.elm"]
graph_ <- Lamdera.Graph.fullGraph ["src/Frontend.elm", "src/Backend.elm", "src/RPC.elm"]
case graph_ of
Left err ->
throw $ Reporting.Exit.makeToReport err
Expand Down Expand Up @@ -157,7 +158,7 @@ selectNextDeps (Global module_ _) node =
-- the deps and then continue as normal
globalDeps & onlyAuthorProjectDeps & Set.delete (Global module_ name)
_ ->
-- When do we have mulitple names...? What does it mean?
-- When would we have mulitple names...? What does this mean?
Set.empty

Manager effectsType ->
Expand Down Expand Up @@ -374,6 +375,7 @@ checkUserConfig appName prodTokenM = do

localConfigItems =
findSecretUses graph "Backend" "app"
& Set.union (findSecretUses graph "RPC" "lamdera_handleEndpoints")
& secretsNormalized
& (++) localFrontendConfigItems

Expand Down
8 changes: 4 additions & 4 deletions test/Test/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ suite = tests $
_ <- io $ checkWithParamsProduction project "always-v0"

"elm-stuff/lamdera/.lamdera-fe-config" & expectContains "frontendOnly"
"elm-stuff/lamdera/.lamdera-be-config" & expectContains "backendOnly"

"elm-stuff/lamdera/.lamdera-fe-config" & expectContains "both"
"elm-stuff/lamdera/.lamdera-be-config" & expectContains "both"

"elm-stuff/lamdera/.lamdera-fe-config" & expectContains "external"

"elm-stuff/lamdera/.lamdera-be-config" & expectContains "backendOnly"
"elm-stuff/lamdera/.lamdera-be-config" & expectContains "both"
"elm-stuff/lamdera/.lamdera-be-config" & expectContains "rpc"

"frontend-app.js" & expectContains "fe-only-from-dashboard"
"backend-app.js" & expectContains "be-only-from-dashboard"

Expand Down
4 changes: 4 additions & 0 deletions test/scenario-always-v0/src/Env.elm
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ both =

external =
"env.external"


rpc =
"env.rpc"
4 changes: 2 additions & 2 deletions test/scenario-always-v0/src/Frontend.elm
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ app =
init : Url.Url -> Nav.Key -> ( Model, Cmd FrontendMsg )
init url key =
let
selfRecursive =
selfRef =
-- This causes the `init` expression to change from a AST.Optimized.Define to a AST.Optimized.Cycle
-- which in the past wasn't properly handled by AppConfig.findSecretUses. This is a regression test.
init url key
init

both =
Env.both
Expand Down

0 comments on commit aeda61f

Please sign in to comment.