on master help sign in
Check for minimal dependencies
33d3c76Evan Czaplicki
builder/src/Elm/Project/Json.hs+21
@@ -240,6 +240,7 @@ read path =
240
240
241 Right project@(Pkg (PkgInfo _ _ _ _ _ deps tests _)) ->
241 Right project@(Pkg (PkgInfo _ _ _ _ _ deps tests _)) ->
242 do checkOverlap "dependencies" "test-dependencies" deps tests
242 do checkOverlap "dependencies" "test-dependencies" deps tests
243+ pkgHasCore deps
243 return project
244 return project
244
245
245 Right project@(App (AppInfo _ srcDirs deps tests trans)) ->
246 Right project@(App (AppInfo _ srcDirs deps tests trans)) ->
@@ -247,6 +248,7 @@ read path =
247 checkOverlap "dependencies" "transitive-dependencies" deps trans
248 checkOverlap "dependencies" "transitive-dependencies" deps trans
248 checkOverlap "test-dependencies" "transitive-dependencies" tests trans
249 checkOverlap "test-dependencies" "transitive-dependencies" tests trans
249 mapM_ doesDirectoryExist srcDirs
250 mapM_ doesDirectoryExist srcDirs
251+ appHasCoreAndJson (Map.union deps trans)
250 return project
252 return project
251
253
252
254
@@ -273,6 +275,25 @@ doesDirectoryExist dir =
273 else throwBadJson (E.BadSrcDir dir)
275 else throwBadJson (E.BadSrcDir dir)
274
276
275
277
278+appHasCoreAndJson :: Map Name a -> Task.Task ()
279+appHasCoreAndJson pkgs =
280+ if Map.member Pkg.core pkgs then
281+
282+ if Map.member Pkg.json pkgs
283+ then return ()
284+ else throwBadJson E.NoAppJson
285+
286+ else
287+ throwBadJson E.NoAppCore
288+
289+
290+pkgHasCore :: Map Name a -> Task.Task ()
291+pkgHasCore pkgs =
292+ if Map.member Pkg.core pkgs
293+ then return ()
294+ else throwBadJson E.NoPkgCore
295+
296+
276
297
277-- JSON DECODE
298-- JSON DECODE
278
299
builder/src/Reporting/Exit/Assets.hs+26
@@ -36,6 +36,9 @@ data ElmJsonProblem
36 = BadJson D.Doc
36 = BadJson D.Doc
37 | BadDepDup String String Pkg.Name [Pkg.Name]
37 | BadDepDup String String Pkg.Name [Pkg.Name]
38 | BadSrcDir FilePath
38 | BadSrcDir FilePath
39+ | NoPkgCore
40+ | NoAppCore
41+ | NoAppJson
39
42
40
43
41
44
@@ -104,6 +107,29 @@ elmJsonProblemToReport problem =
104 , D.reflow "I cannot find that directory though! Is it missing? Is there a typo?"
107 , D.reflow "I cannot find that directory though! Is it missing? Is there a typo?"
105 ]
108 ]
106
109
110+ NoPkgCore ->
111+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
112+ "A package must have \"elm-lang/core\" as a dependency. Try running:"
113+ [ D.indent 4 $ D.green $ "elm install elm-lang/core"
114+ , D.reflow "I need it for the default imports that make `List` and `Maybe` available."
115+ ]
116+
117+ NoAppCore ->
118+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
119+ "An application must have \"elm-lang/core\" as a dependency. Try running:"
120+ [ D.indent 4 $ D.green $ "elm install elm-lang/core"
121+ , D.reflow "It has some supporting code that is needed by every Elm application!"
122+ ]
123+
124+ NoAppJson ->
125+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
126+ "An application must have \"elm-lang/json\" as a dependency. Try running:"
127+ [ D.indent 4 $ D.green $ "elm install elm-lang/json"
128+ , D.reflow "It helps me handle flags and ports."
129+ ]
130+
131+
132+
107 BadDepDup field1 field2 dup dups ->
133 BadDepDup field1 field2 dup dups ->
108 let
134 let
109 packagesAre =
135 packagesAre =