on master help sign in
start using D.fromVersion and stuff like that
commit70e871234a8a32198989f6d13c12df6a8e84d97c authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 3 Jun 2019, 16:36 (7 years ago) parent9acff26
1 file changed+78−26
builder/src/Reporting/Exit.hs+78−26
builder/src/Reporting/Exit.hs+78−26
@@ -43,7 +43,10 @@ import qualified Elm.ModuleName as ModuleName
4343import qualified Elm.Package as Pkg
4444import qualified Elm.Version as V
4545import qualified Http
46+import qualified Json.Decode as Decode
4647import qualified Json.Encode as Encode
48+import qualified Json.String as Json
49+import Parse.Primitives (Row, Col)
4750import Reporting.Doc ((<>))
4851import qualified Reporting.Doc as D
4952import qualified Reporting.Error.Import as Import
@@ -171,16 +174,16 @@ diffToReport diff =
171174 Help.report "UNKNOWN PACKAGE" Nothing
172175 ( "I cannot find a package called:"
173176 )
174− [ D.indent 4 $ D.red $ D.fromUtf8 $ Pkg.toString pkg
177+ [ D.indent 4 $ D.red $ D.fromChars $ Pkg.toChars pkg
175178 , "Maybe you want one of these instead?"
176− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromUtf8 . Pkg.toString) suggestions
179+ , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . Pkg.toChars) suggestions
177180 , "But check <https://package.elm-lang.org> to see all possibilities!"
178181 ]
179182
180183 DiffUnknownVersion _pkg vsn realVersions ->
181184 Help.docReport "UNKNOWN VERSION" Nothing
182185 ( D.fillSep $
183− [ "Version", D.red (D.fromUtf8 (V.toString vsn))
186+ [ "Version", D.red (D.fromVersion vsn)
184187 , "has", "never", "been", "published,", "so", "I"
185188 , "cannot", "diff", "against", "it."
186189 ]
@@ -189,7 +192,7 @@ diffToReport diff =
189192 , D.indent 4 $ D.dullyellow $ D.vcat $
190193 let
191194 sameMajor v1 v2 = V._major v1 == V._major v2
192− mkRow vsns = D.hsep $ map (D.fromUtf8 . V.toString) vsns
195+ mkRow vsns = D.hsep $ map D.fromVersion vsns
193196 in
194197 map mkRow $ List.groupBy sameMajor (List.sort realVersions)
195198 , "Want one of those instead?"
@@ -311,19 +314,19 @@ data Solver
311314
312315
313316data Outline
314− = OutlineHasBadStructure (Json.Error OutlineProblem)
317+ = OutlineHasBadStructure (Decode.Error OutlineProblem)
315318 | OutlineHasBadSrcDirs FilePath [FilePath]
316319
317320
318321data OutlineProblem
319− = OP_BadType Utf8.String
320− | OP_BadPkgName Pkg.BadName
321− | OP_BadVersion Utf8.String
322+ = OP_BadType
323+ | OP_BadPkgName Row Col
324+ | OP_BadVersion Row Col
322325 | OP_BadConstraint C.Error
323− | OP_BadModuleName Utf8.String
324− | OP_BadModuleHeaderTooLong Utf8.String
325− | OP_BadDependencyName Utf8.String
326− | OP_BadLicense Utf8.String [Utf8.String]
326+ | OP_BadModuleName Row Col
327+ | OP_BadModuleHeaderTooLong
328+ | OP_BadDependencyName Row Col
329+ | OP_BadLicense Json.String [Json.String]
327330 | OP_BadSummaryTooLong
328331 | OP_NoSrcDirs
329332
@@ -426,7 +429,7 @@ _toReport exit =
426429 Help.docReport "CANNOT BUMP" (Just "elm.json")
427430 ( D.fillSep
428431 ["Your","elm.json","says","I","should","bump","relative","to","version"
429− ,D.red (D.fromUtf8 (V.toString vsn)) <> ","
432+ ,D.red (D.fromVersion vsn) <> ","
430433 ,"but","I","cannot","find","that","version","on","<https://package.elm-lang.org>."
431434 ,"That","means","there","is","no","API","for","me","to","diff","against","and"
432435 ,"figure","out","if","these","are","MAJOR,","MINOR,","or","PATCH","changes."
@@ -435,7 +438,7 @@ _toReport exit =
435438 [ D.fillSep $
436439 ["Try","bumping","again","after","changing","the",D.dullyellow "\"version\"","in","elm.json"]
437440 ++ if length versions == 1 then ["to:"] else ["to","one","of","these:"]
438− , D.vcat $ map (D.green . D.fromUtf8 . V.toString) versions
441+ , D.vcat $ map (D.green . D.fromVersion) versions
439442 ]
440443
441444 BumpMustHaveLatestRegistry problem ->
@@ -456,7 +459,7 @@ _toReport exit =
456459 Help.docReport "INVALID VERSION" Nothing
457460 ( D.fillSep
458461 ["I","cannot","publish"
459− ,D.red (D.fromUtf8 (V.toString vsn))
462+ ,D.red (D.fromVersion vsn)
460463 ,"as","the","initial","version."
461464 ]
462465 )
@@ -470,7 +473,7 @@ _toReport exit =
470473 Help.docReport "ALREADY PUBLISHED" Nothing
471474 ( D.vcat
472475 [ D.fillSep
473− [ "Version", D.green (D.fromUtf8 (V.toString vsn))
476+ [ "Version", D.green (D.fromVersion vsn)
474477 , "has", "already", "been", "published.", "You", "cannot"
475478 , "publish", "it", "again!"
476479 ]
@@ -487,14 +490,14 @@ _toReport exit =
487490 Help.docReport "INVALID VERSION" (Just "elm.json")
488491 ( D.fillSep $
489492 ["Your","elm.json","says","the","next","version","should","be"
490− ,D.red (D.fromUtf8 (V.toString statedVersion)) <> ","
493+ ,D.red (D.fromVersion statedVersion) <> ","
491494 ,"but","that","is","not","valid","based","on","the","previously"
492495 ,"published","versions."
493496 ]
494497 )
495498 [ D.fillSep $
496499 ["Change","the","version","back","to"
497− ,D.green (D.fromUtf8 (V.toString latestVersion))
500+ ,D.green (D.fromVersion latestVersion)
498501 ,"which","is","the","most","recently","published","version."
499502 ,"From","there,","have","Elm","bump","the","version","by","running:"
500503 ]
@@ -509,7 +512,7 @@ _toReport exit =
509512 (
510513 D.fillSep $
511514 ["Your","elm.json","says","the","next","version","should","be"
512− ,D.red (D.fromUtf8 (V.toString new)) <> ","
515+ ,D.red (D.fromVersion new) <> ","
513516 ,"indicating","a",D.fromChars (M.toChars magnitude)
514517 ,"change","to","the","public","API."
515518 ,"This","does","not","match","the","API","diff","given","by:"
@@ -522,7 +525,7 @@ _toReport exit =
522525 ["This","command","says","this","is","a"
523526 ,D.fromChars (M.toChars realMagnitude)
524527 ,"change,","so","the","next","version","should","be"
525− ,D.green (D.fromUtf8 (V.toString realNew)) <> "."
528+ ,D.green (D.fromVersion realNew) <> "."
526529 ,"Double","check","everything","to","make","sure","you"
527530 ,"are","publishing","what","you","want!"
528531 ]
@@ -678,10 +681,10 @@ detailsToReport details =
678681 DetailsBadElmInPkg constraint ->
679682 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
680683 "Your elm.json says this package needs a version of Elm in this range:"
681− [ D.indent 4 $ D.dullyellow $ D.fromUtf8 $ C.toString constraint
684+ [ D.indent 4 $ D.dullyellow $ D.fromChars $ C.toChars constraint
682685 , D.fillSep
683686 [ "But", "you", "are", "using", "Elm"
684− , D.red (D.fromUtf8 (V.toString V.compiler))
687+ , D.red (D.fromVersion V.compiler)
685688 , "right", "now."
686689 ]
687690 ]
@@ -691,9 +694,9 @@ detailsToReport details =
691694 "Your elm.json says this application needs a different version of Elm."
692695 [ D.fillSep
693696 [ "It", "requires"
694− , D.green (D.fromUtf8 (V.toString version)) <> ","
697+ , D.green (D.fromVersion version) <> ","
695698 , "but", "you", "are", "using"
696− , D.red (D.fromUtf8 (V.toString V.compiler))
699+ , D.red (D.fromVersion V.compiler)
697700 , "right", "now."
698701 ]
699702 ]
@@ -701,8 +704,8 @@ detailsToReport details =
701704 DetailsHandEditedDependencies ->
702705 error "TODO DetailsHandEditedDependencies"
703706
704− DetailsBadOutline problem ->
705− error "TODO DetailsBadOutline" problem
707+ DetailsBadOutline outlineProblem ->
708+ toOutlineReport outlineProblem
706709
707710 DetailsCannotGetRegistry problem ->
708711 error "TODO DetailsCannotGetRegistry" problem
@@ -826,3 +829,52 @@ makeToReport make =
826829
827830 MakeCannotLoadArtifacts ->
828831 error "TODO MakeCannotLoadArtifacts"
832+
833+
834+
835+-- OUTLINE
836+
837+
838+toOutlineReport :: Outline -> Help.Report
839+toOutlineReport problem =
840+ case problem of
841+ OutlineHasBadSrcDirs dir dirs ->
842+ error "TODO OutlineHasBadSrcDirs" dir dirs
843+
844+ OutlineHasBadStructure decodeError ->
845+ error "TODO OutlineHasBadStructure" decodeError toOutlineProblemReport
846+
847+
848+toOutlineProblemReport :: OutlineProblem -> Help.Report
849+toOutlineProblemReport problem =
850+ case problem of
851+ OP_BadType ->
852+ error "TODO OP_BadType"
853+
854+ OP_BadPkgName row col ->
855+ error "TODO OP_BadPkgName" row col
856+
857+ OP_BadVersion row col ->
858+ error "TODO OP_BadVersion" row col
859+
860+ OP_BadConstraint constraintError ->
861+ error "TODO OP_BadConstraint" constraintError
862+
863+ OP_BadModuleName row col ->
864+ error "TODO OP_BadModuleName" row col
865+
866+ OP_BadModuleHeaderTooLong ->
867+ error "TODO OP_BadModuleHeaderTooLong"
868+
869+ OP_BadDependencyName row col ->
870+ error "TODO OP_BadDependencyName"
871+
872+ OP_BadLicense badLicense suggestions ->
873+ error "TODO OP_BadLicense" badLicense suggestions
874+
875+ OP_BadSummaryTooLong ->
876+ error "TODO OP_BadSummaryTooLong"
877+
878+ OP_NoSrcDirs ->
879+ error "TODO OP_NoSrcDirs"
880+