Skip to content

Commit

Permalink
Add rough reason context to DetailsHandEditedDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
supermario committed May 6, 2024
1 parent e8342a9 commit b0a036e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions builder/src/Elm/Details.hs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ verifyApp env time outline@(Outline.AppOutline elmVersion srcDirs direct _ _ _)
if Map.size stated == Map.size actual
then verifyDependencies env time (ValidApp srcDirs) actual direct
else Task.throw $ Exit.DetailsHandEditedDependencies
$ "The stated and actual dependencies do not match.\n\n"
++ "Stated: " ++ show stated ++ "\n\nActual: " ++ show actual
else
Task.throw $ Exit.DetailsBadElmInAppOutline elmVersion

Expand Down Expand Up @@ -289,14 +291,17 @@ union tieBreaker deps1 deps2 =

noDups :: k -> v -> v -> Task v
noDups _ _ _ =
Task.throw Exit.DetailsHandEditedDependencies
Task.throw $ Exit.DetailsHandEditedDependencies
"The same dependency is listed in multiple places in your elm.json file."


allowEqualDups :: (Eq v) => k -> v -> v -> Task v
allowEqualDups :: (Eq v, Show v) => k -> v -> v -> Task v
allowEqualDups _ v1 v2 =
if v1 == v2
then return v1
else Task.throw Exit.DetailsHandEditedDependencies
else Task.throw $ Exit.DetailsHandEditedDependencies
$ "The same dependency is listed in multiple places in your elm.json file, but with different constraints.\n\n"
++ "Dep 1: " ++ show v1 ++ "\n\nDep 2: " ++ show v2



Expand Down
7 changes: 5 additions & 2 deletions builder/src/Reporting/Exit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ data Details
| DetailsBadElmInPkg C.Constraint
| DetailsBadElmInAppOutline V.Version
| DetailsHandEditedDependencies
String -- @LAMDERA addition: reason
| DetailsBadOutline Outline
| DetailsCannotGetRegistry RegistryProblem
| DetailsBadDeps FilePath [DetailsBadDep]
Expand Down Expand Up @@ -1356,11 +1357,13 @@ toDetailsReport details =
, D.reflow $ "Lamdera hint: modify your elm.json to \"elm-version\": \"0.19.1\"."
]

DetailsHandEditedDependencies ->
DetailsHandEditedDependencies reason ->
Help.report "ERROR IN DEPENDENCIES" (Just "elm.json")
"It looks like the dependencies elm.json in were edited by hand (or by a 3rd\
\ party tool) leaving them in an invalid state."
[ D.fillSep
[ D.reflow $
"Reason: " ++ reason
, D.fillSep
["Try","to","change","them","back","to","what","they","were","before!"
,"It","is","much","more","reliable","to","add","dependencies","with",D.green "lamdera install" <> "."
]
Expand Down

0 comments on commit b0a036e

Please sign in to comment.