on master help sign in
Nicer behavior if elm.json does not exist
b5dcc46Evan Czaplicki
ui/browser/src/Errors.elm+16−6
@@ -76,13 +76,23 @@ viewErrorHelp error =
76-- VIEW HEADER
76-- VIEW HEADER
77
77
78
78
79−viewHeader : String -> String -> Html msg
79+viewHeader : String -> Maybe String -> Html msg
80−viewHeader title filePath =
80+viewHeader title maybeFilePath =
81 let
81 let
82− leftover = 76 - String.length title
82+ left = "-- " ++ title ++ " "
83− header = "-- " ++ title ++ " " ++ String.padLeft leftover '-' (" " ++ filePath) ++ "\n\n"
83+ right =
84+ case maybeFilePath of
85+ Nothing ->
86+ ""
87+ Just filePath ->
88+ " " ++ filePath
84 in
89 in
85− span [ style "color" "rgb(51,187,200)" ] [ text header ]
90+ span [ style "color" "rgb(51,187,200)" ] [ text (fill left right ++ "\n\n") ]
91+
92+
93+fill : String -> String -> String
94+fill left right =
95+ left ++ String.repeat (80 - String.length left - String.length right) "-" ++ right
86
96
87
97
88
98
@@ -109,7 +119,7 @@ viewBadModule { path, problems } =
109
119
110viewProblem : String -> Error.Problem -> Html msg
120viewProblem : String -> Error.Problem -> Html msg
111viewProblem filePath problem =
121viewProblem filePath problem =
112− span [] (viewHeader problem.title filePath :: viewMessage problem.message)
122+ span [] (viewHeader problem.title (Just filePath) :: viewMessage problem.message)
113
123
114
124
115viewSeparator : String -> String -> Html msg
125viewSeparator : String -> String -> Html msg
ui/browser/src/Index.elm+25−11
@@ -41,7 +41,7 @@ type alias Flags =
41 , dirs : List String
41 , dirs : List String
42 , files : List File
42 , files : List File
43 , readme : Maybe String
43 , readme : Maybe String
44− , project : Project.Project
44+ , project : Maybe Project.Project
45 , exactDeps : Dict.Dict String Version.Version
45 , exactDeps : Dict.Dict String Version.Version
46 }
46 }
47
47
@@ -64,7 +64,7 @@ decoder =
64 (D.field "dirs" (D.list D.string))
64 (D.field "dirs" (D.list D.string))
65 (D.field "files" (D.list fileDecoder))
65 (D.field "files" (D.list fileDecoder))
66 (D.field "readme" (D.nullable D.string))
66 (D.field "readme" (D.nullable D.string))
67− (D.field "project" Project.decoder)
67+ (D.field "project" (D.nullable Project.decoder))
68 (D.field "exactDeps" (D.dict Version.decoder))
68 (D.field "exactDeps" (D.dict Version.decoder))
69
69
70
70
@@ -103,21 +103,35 @@ view model =
103 [ header [ class "header" ] []
103 [ header [ class "header" ] []
104 , div [ class "content" ]
104 , div [ class "content" ]
105 [ Navigator.view root pwd
105 [ Navigator.view root pwd
106− , section [ class "left-column" ]
106+ , viewLeftColumn dirs files readme
107− [ viewFiles dirs files
108− , viewReadme readme
109− ]
110− , section [ class "right-column" ]
111− [ viewProjectSummary project
112− , viewDeps exactDeps project
113− , viewTestDeps exactDeps project
107+ , viewRightColumn exactDeps project
114− ]
115 , div [ style "clear" "both" ] []
108 , div [ style "clear" "both" ] []
116 ]
109 ]
117 ]
110 ]
118 }
111 }
119
112
120
113
114+viewLeftColumn : List String -> List File -> Maybe String -> Html msg
115+viewLeftColumn dirs files readme =
116+ section [ class "left-column" ]
117+ [ viewFiles dirs files
118+ , viewReadme readme
119+ ]
120+
121+
122+viewRightColumn : ExactDeps -> Maybe Project.Project -> Html msg
123+viewRightColumn exactDeps maybeProject =
124+ section [ class "right-column" ] <|
125+ case maybeProject of
126+ Nothing ->
127+ []
128+
129+ Just project ->
130+ [ viewProjectSummary project
131+ , viewDeps exactDeps project
132+ , viewTestDeps exactDeps project
133+ ]
134+
121
135
122-- VIEW README
136-- VIEW README
123
137
ui/terminal/src/Develop/Generate/Index.hs+6−2
@@ -88,10 +88,14 @@ getFlags :: FilePath -> FilePath -> IO Flags
88getFlags root pwd =
88getFlags root pwd =
89 do (dirs, files) <- getDirsAndFiles pwd
89 do (dirs, files) <- getDirsAndFiles pwd
90 readme <- getReadme pwd
90 readme <- getReadme pwd
91+ exists <- Dir.doesFileExist (root </> "elm.json")
91
92
92 maybeSummary <-
93 maybeSummary <-
94+ if exists then
93− Task.try Progress.silentReporter $
95+ Task.try Progress.silentReporter $
94− Verify.verify root =<< Project.read "elm.json"
96+ Verify.verify root =<< Project.read (root </> "elm.json")
97+ else
98+ return Nothing
95
99
96 return $
100 return $
97 Flags
101 Flags