on master help sign in
Nicer behavior if elm.json does not exist
commitb5dcc460f1de27915e416b56f92f11de70588b0a authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 27 Jun 2018, 14:32 (8 years ago) parentcb35c1e
3 files changed+47−19
ui/browser/src/Errors.elm+16−6 ui/browser/src/Index.elm+25−11 ui/terminal/src/Develop/Generate/Index.hs+6−2
ui/browser/src/Errors.elm+16−6
@@ -76,13 +76,23 @@ viewErrorHelp error =
7676-- VIEW HEADER
7777
7878
79−viewHeader : String -> String -> Html msg
80−viewHeader title filePath =
79+viewHeader : String -> Maybe String -> Html msg
80+viewHeader title maybeFilePath =
8181 let
82− leftover = 76 - String.length title
83− header = "-- " ++ title ++ " " ++ String.padLeft leftover '-' (" " ++ filePath) ++ "\n\n"
82+ left = "-- " ++ title ++ " "
83+ right =
84+ case maybeFilePath of
85+ Nothing ->
86+ ""
87+ Just filePath ->
88+ " " ++ filePath
8489 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
8696
8797
8898
@@ -109,7 +119,7 @@ viewBadModule { path, problems } =
109119
110120viewProblem : String -> Error.Problem -> Html msg
111121viewProblem filePath problem =
112− span [] (viewHeader problem.title filePath :: viewMessage problem.message)
122+ span [] (viewHeader problem.title (Just filePath) :: viewMessage problem.message)
113123
114124
115125viewSeparator : String -> String -> Html msg
ui/browser/src/Index.elm+25−11
@@ -41,7 +41,7 @@ type alias Flags =
4141 , dirs : List String
4242 , files : List File
4343 , readme : Maybe String
44− , project : Project.Project
44+ , project : Maybe Project.Project
4545 , exactDeps : Dict.Dict String Version.Version
4646 }
4747
@@ -64,7 +64,7 @@ decoder =
6464 (D.field "dirs" (D.list D.string))
6565 (D.field "files" (D.list fileDecoder))
6666 (D.field "readme" (D.nullable D.string))
67− (D.field "project" Project.decoder)
67+ (D.field "project" (D.nullable Project.decoder))
6868 (D.field "exactDeps" (D.dict Version.decoder))
6969
7070
@@ -103,21 +103,35 @@ view model =
103103 [ header [ class "header" ] []
104104 , div [ class "content" ]
105105 [ Navigator.view root pwd
106− , section [ class "left-column" ]
107− [ viewFiles dirs files
108− , viewReadme readme
109− ]
110− , section [ class "right-column" ]
111− [ viewProjectSummary project
112− , viewDeps exactDeps project
113− , viewTestDeps exactDeps project
114− ]
106+ , viewLeftColumn dirs files readme
107+ , viewRightColumn exactDeps project
115108 , div [ style "clear" "both" ] []
116109 ]
117110 ]
118111 }
119112
120113
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+
121135
122136-- VIEW README
123137
ui/terminal/src/Develop/Generate/Index.hs+6−2
@@ -88,10 +88,14 @@ getFlags :: FilePath -> FilePath -> IO Flags
8888getFlags root pwd =
8989 do (dirs, files) <- getDirsAndFiles pwd
9090 readme <- getReadme pwd
91+ exists <- Dir.doesFileExist (root </> "elm.json")
9192
9293 maybeSummary <-
93− Task.try Progress.silentReporter $
94− Verify.verify root =<< Project.read "elm.json"
94+ if exists then
95+ Task.try Progress.silentReporter $
96+ Verify.verify root =<< Project.read (root </> "elm.json")
97+ else
98+ return Nothing
9599
96100 return $
97101 Flags