on master help sign in
Check for minimal dependencies

Should fix https://github.com/elm-lang/elm-compiler/issues/1706

commit33d3c760aa2b8f411c9e2d739c35efe677732078 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 23 May 2018, 10:21 (8 years ago) parent8a14611
2 files changed+47
builder/src/Elm/Project/Json.hs+21 builder/src/Reporting/Exit/Assets.hs+26
builder/src/Elm/Project/Json.hs+21
@@ -240,6 +240,7 @@ read path =
240240
241241 Right project@(Pkg (PkgInfo _ _ _ _ _ deps tests _)) ->
242242 do checkOverlap "dependencies" "test-dependencies" deps tests
243+ pkgHasCore deps
243244 return project
244245
245246 Right project@(App (AppInfo _ srcDirs deps tests trans)) ->
@@ -247,6 +248,7 @@ read path =
247248 checkOverlap "dependencies" "transitive-dependencies" deps trans
248249 checkOverlap "test-dependencies" "transitive-dependencies" tests trans
249250 mapM_ doesDirectoryExist srcDirs
251+ appHasCoreAndJson (Map.union deps trans)
250252 return project
251253
252254
@@ -273,6 +275,25 @@ doesDirectoryExist dir =
273275 else throwBadJson (E.BadSrcDir dir)
274276
275277
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+
276297
277298-- JSON DECODE
278299
builder/src/Reporting/Exit/Assets.hs+26
@@ -36,6 +36,9 @@ data ElmJsonProblem
3636 = BadJson D.Doc
3737 | BadDepDup String String Pkg.Name [Pkg.Name]
3838 | BadSrcDir FilePath
39+ | NoPkgCore
40+ | NoAppCore
41+ | NoAppJson
3942
4043
4144
@@ -104,6 +107,29 @@ elmJsonProblemToReport problem =
104107 , D.reflow "I cannot find that directory though! Is it missing? Is there a typo?"
105108 ]
106109
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+
107133 BadDepDup field1 field2 dup dups ->
108134 let
109135 packagesAre =