on master help sign in
add back checks for required dependencies
7c2dedfEvan Czaplicki
builder/src/Elm/Outline.hs+14−8
@@ -178,14 +178,20 @@ read root =
178
178
179 Right outline ->
179 Right outline ->
180 case outline of
180 case outline of
181− Pkg _ ->
181+ Pkg (PkgOutline _ _ _ _ _ deps _ _) ->
182+ return $
183+ if Map.notMember Pkg.core deps
184+ then Left Exit.OutlineNoPkgCore
182− return $ Right outline
185+ else Right outline
183−
186+
184− App (AppOutline _ srcDirs _ _ _ _) ->
187+ App (AppOutline _ srcDirs deps _ _ _)
188+ | Map.notMember Pkg.core deps -> return $ Left Exit.OutlineNoAppCore
189+ | Map.notMember Pkg.json deps -> return $ Left Exit.OutlineNoAppJson
190+ | otherwise ->
185− do badDirs <- filterM (isBadSrcDir root) (NE.toList srcDirs)
191+ do badDirs <- filterM (isBadSrcDir root) (NE.toList srcDirs)
186− case badDirs of
192+ case badDirs of
187− [] -> return $ Right outline
193+ [] -> return $ Right outline
188− d:ds -> return $ Left (Exit.OutlineHasBadSrcDirs d ds)
194+ d:ds -> return $ Left (Exit.OutlineHasBadSrcDirs d ds)
189
195
190
196
191isBadSrcDir :: FilePath -> FilePath -> IO Bool
197isBadSrcDir :: FilePath -> FilePath -> IO Bool
builder/src/Reporting/Exit.hs+41−3
@@ -641,6 +641,9 @@ data Solver
641data Outline
641data Outline
642 = OutlineHasBadStructure (Decode.Error OutlineProblem)
642 = OutlineHasBadStructure (Decode.Error OutlineProblem)
643 | OutlineHasBadSrcDirs FilePath [FilePath]
643 | OutlineHasBadSrcDirs FilePath [FilePath]
644+ | OutlineNoPkgCore
645+ | OutlineNoAppCore
646+ | OutlineNoAppJson
644
647
645
648
646data OutlineProblem
649data OutlineProblem
@@ -908,12 +911,47 @@ makeToReport make =
908toOutlineReport :: Outline -> Help.Report
911toOutlineReport :: Outline -> Help.Report
909toOutlineReport problem =
912toOutlineReport problem =
910 case problem of
913 case problem of
911− OutlineHasBadSrcDirs dir dirs ->
912− error "TODO OutlineHasBadSrcDirs" dir dirs
913−
914 OutlineHasBadStructure decodeError ->
914 OutlineHasBadStructure decodeError ->
915 error "TODO OutlineHasBadStructure" decodeError toOutlineProblemReport
915 error "TODO OutlineHasBadStructure" decodeError toOutlineProblemReport
916
916
917+ OutlineHasBadSrcDirs dir dirs ->
918+ case dirs of
919+ [] ->
920+ Help.report "MISSING SOURCE DIRECTORY" (Just "elm.json")
921+ "The \"source-directories\" in your elm.json lists the following directory:"
922+ [ D.indent 4 $ D.dullyellow $ D.fromChars dir
923+ , D.reflow $
924+ "I cannot find it though. Is it missing? Is there a typo?"
925+ ]
926+
927+ _:_ ->
928+ Help.report "MISSING SOURCE DIRECTORIES" (Just "elm.json")
929+ "The \"source-directories\" in your elm.json lists the following directories:"
930+ [ D.indent 4 $ D.dullyellow $ D.fromChars dir
931+ , D.reflow $
932+ "I cannot find them though. Are they missing? Are there typos?"
933+ ]
934+
935+ OutlineNoPkgCore ->
936+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
937+ "A package must have \"elm/core\" as a dependency. Try running:"
938+ [ D.indent 4 $ D.green $ "elm install elm/core"
939+ , D.reflow "I need it for the default imports that make `List` and `Maybe` available."
940+ ]
941+
942+ OutlineNoAppCore ->
943+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
944+ "An application must have \"elm/core\" as a dependency. Try running:"
945+ [ D.indent 4 $ D.green $ "elm install elm/core"
946+ , D.reflow "It has some supporting code that is needed by every Elm application!"
947+ ]
948+
949+ OutlineNoAppJson ->
950+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
951+ "An application must have \"elm/json\" as a dependency. Try running:"
952+ [ D.indent 4 $ D.green $ "elm install elm/json"
953+ , D.reflow "It helps me handle flags and ports."
954+ ]
917
955
918toOutlineProblemReport :: OutlineProblem -> Help.Report
956toOutlineProblemReport :: OutlineProblem -> Help.Report
919toOutlineProblemReport problem =
957toOutlineProblemReport problem =