@@ -1,8 +1,6 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit
2module Reporting.Exit
5− , Init(..)
3+ ( Init(..)
6 , initToReport
4 , initToReport
@@ -12,6 +10,9 @@ module Reporting.Exit
12 , bumpToReport
10 , bumpToReport
13 , newPackageOverview
11 , newPackageOverview
15 , Install(..)
16 , Install(..)
16 , installToReport
17 , installToReport
@@ -30,6 +31,7 @@ module Reporting.Exit
30 , makeToReport
31 , makeToReport
32 , DocsProblem(..)
33 , DocsProblem(..)
33 , toString
35 , toString
34 , toStderr
36 , toStderr
@@ -60,39 +62,6 @@ import qualified Reporting.Error as Error
63−-- ALL POSSIBLE ERRORS
68− = PublishMustHaveLatestRegistry RegistryProblem
70− | PublishNotInitialVersion V.Version
71− | PublishAlreadyPublished V.Version
72− | PublishInvalidBump V.Version V.Version
73− | PublishBadBump V.Version V.Version M.Magnitude V.Version M.Magnitude
79− | PublishCannotGetTag Http.Error
80− | PublishCannotGetZip Http.Error
81− | PublishCannotDecodeZip
82− | PublishCannotGetDocs DocsProblem
83− | PublishCannotRegister Http.Error
84− | PublishMissingTag V.Version
86− | PublishLocalChanges V.Version
@@ -286,218 +255,41 @@ newPackageOverview =
289−-- INSTALL
258+-- PUBLISH
294− | InstallNoArgs FilePath
295− | InstallNoOnlineSolution
296− | InstallNoOfflineSolution
297− | InstallHadSolverTrouble Solver
298− | InstallUnknownPackageOnline [Pkg.Name]
299− | InstallUnknownPackageOffline [Pkg.Name]
300− | InstallHasBadDetails Details
303−installToReport :: Install -> Help.Report
304−installToReport exit =
307− Help.report "NEW PROJECT?" Nothing
308− "Are you trying to start a new project? Try this command instead:"
309− [ D.indent 4 $ D.green "elm init"
310− , D.reflow "It will help you get started!"
313− InstallNoArgs elmHome ->
314− Help.report "INSTALL WHAT?" Nothing
315− "I am expecting commands like:"
316− [ D.green $ D.indent 4 $ D.vcat $
317− [ "elm install elm/http"
318− , "elm install elm/json"
319− , "elm install elm/random"
322− ["In","JavaScript","folks","run","`npm install`","to","start","projects."
323− ,"\"Gotta","download","everything!\"","But","why","download","packages"
324− ,"again","and","again?","Instead,","Elm","caches","packages","in"
325− ,D.dullyellow (D.fromChars elmHome)
326− ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
327− ,"Elm","projects","check","that","cache","before","trying","the","internet."
328− ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
329− ,"easier","to","work","offline.","As","a","result"
330− ,D.dullcyan "elm install","is","only","for","adding","dependencies","to","elm.json,"
331− ,"whereas",D.dullcyan "elm make","is","in","charge","of","gathering","dependencies"
332− ,"and","building","everything.","So","maybe","try",D.green "elm make","instead?"
336− InstallNoOnlineSolution ->
337− Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO recommend using solver in `elm reactor`
338− "This usually happens if you try to modify dependency constraints by\
339− \ hand. I recommend deleting any dependency you added recently (or all\
340− \ of them if things are bad) and then adding them again with:"
341− [ D.indent 4 $ D.green "elm install"
343− "And do not be afaid to ask for help on Slack if you get stuck!"
346− InstallNoOfflineSolution ->
347− error "TODO InstallNoOfflineSolution"
349− InstallHadSolverTrouble solver ->
350− error "TODO InstallHadSolverTrouble" solver
352− InstallUnknownPackageOnline suggestions ->
353− error "TODO InstallUnknownPackageOnline" suggestions
355− InstallUnknownPackageOffline suggestions ->
356− error "TODO InstallUnknownPackageOffline" suggestions
358− InstallHasBadDetails _ ->
359− error "TODO InstallHasBadDetails"
362−{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
363− Help.report "OLD DEPENDENCIES" (Just "elm.json")
364− ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
366− [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
368− "This may be because it is not upgraded yet. It may be because a\
369− \ better solution came along, so there was no need to upgrade it.\
370− \ Etc. Try asking around on Slack to learn more about the topic."
372− "Whatever the case, please be kind to the relevant package authors! Having\
373− \ friendly interactions with users is great motivation, and conversely, getting\
374− \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
375− \ authors are humans with families, friends, jobs, vacations, responsibilities,\
376− \ goals, etc. They face obstacles outside of their technical work you will never\
377− \ know about, so please assume the best and try to be patient and supportive!"
387− = SolverBadCacheData Pkg.Name V.Version
388− | SolverBadHttpData Pkg.Name V.Version
389− | SolverBadHttp Http.Error
397− = OutlineHasBadStructure (Decode.Error OutlineProblem)
398− | OutlineHasBadSrcDirs FilePath [FilePath]
403− | OP_BadPkgName Row Col
404− | OP_BadVersion Row Col
405− | OP_BadConstraint C.Error
406− | OP_BadModuleName Row Col
407− | OP_BadModuleHeaderTooLong
408− | OP_BadDependencyName Row Col
409− | OP_BadLicense Json.String [Json.String]
410− | OP_BadSummaryTooLong
421− | DetailsNoOfflineSolution
422− | DetailsSolverProblem Solver
423− | DetailsBadElmInPkg C.Constraint
424− | DetailsBadElmInAppOutline V.Version
425− | DetailsHandEditedDependencies
426− | DetailsBadOutline Outline
427− | DetailsCannotGetRegistry RegistryProblem
428− | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
432− = RP_Http Http.Error
437− = PP_BadEndpointRequest Http.Error
438− | PP_BadEndpointContent
439− | PP_BadArchiveRequest Http.Error
440− | PP_BadArchiveContent
441− | PP_BadArchiveHash String String
450− | MakeCannotOptimizeAndDebug
451− | MakeBlockedByDetailsProblem Details
452− | MakeAppNeedsFileNames
453− | MakePkgNeedsExposing
454− | MakeMultipleFilesIntoHtml
455− | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
456− | MakeCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
457− | MakeCannotBuild BuildProblem
458− | MakeCannotLoadArtifacts
462− = BuildModuleProblems Error.Module [Error.Module]
463− | BuildProjectProblem BuildProjectProblem
466−data BuildProjectProblem
261+data Publish
467− = BP_PathUnknown FilePath
262+ = PublishNoOutline
468− | BP_WithBadExtension FilePath
263+ | PublishBadOutline Outline
469− | BP_WithAmbiguousSrcDir FilePath FilePath
264+ | PublishMustHaveLatestRegistry RegistryProblem
470− | BP_MainPathDuplicate FilePath FilePath
265+ | PublishApplication
471− | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
266+ | PublishNotInitialVersion V.Version
472− | BP_CannotLoadDependencies
267+ | PublishAlreadyPublished V.Version
473− | BP_Cycle ModuleName.Raw [ModuleName.Raw]
268+ | PublishInvalidBump V.Version V.Version
474− | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
269+ | PublishBadBump V.Version V.Version M.Magnitude V.Version M.Magnitude
475−
270+ | PublishNoSummary
476−
271+ | PublishNoExposed
477−
272+ | PublishNoReadme
478−-- RENDERERS
273+ | PublishShortReadme
479−
274+ | PublishNoLicense
480−
275+ | PublishCannotGetTag Http.Error
481−toString :: Help.Report -> String
276+ | PublishCannotGetZip Http.Error
482−toString report =
277+ | PublishCannotDecodeZip
483− Help.toString (Help.reportToDoc report)
278+ | PublishCannotGetDocs DocsProblem
484−
279+ | PublishCannotRegister Http.Error
485−
280+ | PublishMissingTag V.Version
486−toStderr :: Help.Report -> IO ()
281+ | PublishNoGit
487−toStderr report =
282+ | PublishLocalChanges V.Version
488− Help.toStderr (Help.reportToDoc report)
491−toJson :: Help.Report -> Encode.Value
493− Help.reportToJson report
496−_toReport :: Exit -> Help.Report
285+publishToReport :: Publish -> Help.Report
497−_toReport exit =
286+publishToReport publish =
498− case exit of
287+ case publish of
289+ error "TODO PublishNoOutline"
500− -- publish
291+ PublishBadOutline problem ->
292+ error "TODO PublishBadOutline" problem
502 PublishMustHaveLatestRegistry problem ->
294 PublishMustHaveLatestRegistry problem ->
503 error "TODO PublishMustHaveLatestRegistry" problem
295 error "TODO PublishMustHaveLatestRegistry" problem
@@ -609,12 +401,12 @@ _toReport exit =
611 PublishNoReadme ->
403 PublishNoReadme ->
612− badReadmeReport "NO README" $
404+ toBadReadmeReport "NO README" $
613 "Every published package must have a helpful README.md\
405 "Every published package must have a helpful README.md\
614 \ file, but I do not see one in your project."
406 \ file, but I do not see one in your project."
616 PublishShortReadme ->
408 PublishShortReadme ->
617− badReadmeReport "SHORT README" $
409+ toBadReadmeReport "SHORT README" $
618 "This README.md is too short. Having more details will help\
410 "This README.md is too short. Having more details will help\
619 \ people assess your package quickly and fairly."
411 \ people assess your package quickly and fairly."
@@ -695,8 +487,8 @@ _toReport exit =
698−badReadmeReport :: String -> String -> Help.Report
490+toBadReadmeReport :: String -> String -> Help.Report
699−badReadmeReport title summary =
491+toBadReadmeReport title summary =
700 Help.report title (Just "README.md") summary
492 Help.report title (Just "README.md") summary
701 [ D.reflow $
493 [ D.reflow $
702 "When people look at your README, they are wondering:"
494 "When people look at your README, they are wondering:"
@@ -719,6 +511,224 @@ badReadmeReport title summary =
518+ = DP_Http Http.Error
529+ | InstallNoArgs FilePath
530+ | InstallNoOnlineSolution
531+ | InstallNoOfflineSolution
532+ | InstallHadSolverTrouble Solver
533+ | InstallUnknownPackageOnline [Pkg.Name]
534+ | InstallUnknownPackageOffline [Pkg.Name]
535+ | InstallHasBadDetails Details
538+installToReport :: Install -> Help.Report
539+installToReport exit =
542+ Help.report "NEW PROJECT?" Nothing
543+ "Are you trying to start a new project? Try this command instead:"
544+ [ D.indent 4 $ D.green "elm init"
545+ , D.reflow "It will help you get started!"
548+ InstallNoArgs elmHome ->
549+ Help.report "INSTALL WHAT?" Nothing
550+ "I am expecting commands like:"
551+ [ D.green $ D.indent 4 $ D.vcat $
552+ [ "elm install elm/http"
553+ , "elm install elm/json"
554+ , "elm install elm/random"
557+ ["In","JavaScript","folks","run","`npm install`","to","start","projects."
558+ ,"\"Gotta","download","everything!\"","But","why","download","packages"
559+ ,"again","and","again?","Instead,","Elm","caches","packages","in"
560+ ,D.dullyellow (D.fromChars elmHome)
561+ ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
562+ ,"Elm","projects","check","that","cache","before","trying","the","internet."
563+ ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
564+ ,"easier","to","work","offline.","As","a","result"
565+ ,D.dullcyan "elm install","is","only","for","adding","dependencies","to","elm.json,"
566+ ,"whereas",D.dullcyan "elm make","is","in","charge","of","gathering","dependencies"
567+ ,"and","building","everything.","So","maybe","try",D.green "elm make","instead?"
571+ InstallNoOnlineSolution ->
572+ Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO recommend using solver in `elm reactor`
573+ "This usually happens if you try to modify dependency constraints by\
574+ \ hand. I recommend deleting any dependency you added recently (or all\
575+ \ of them if things are bad) and then adding them again with:"
576+ [ D.indent 4 $ D.green "elm install"
578+ "And do not be afaid to ask for help on Slack if you get stuck!"
581+ InstallNoOfflineSolution ->
582+ error "TODO InstallNoOfflineSolution"
584+ InstallHadSolverTrouble solver ->
585+ error "TODO InstallHadSolverTrouble" solver
587+ InstallUnknownPackageOnline suggestions ->
588+ error "TODO InstallUnknownPackageOnline" suggestions
590+ InstallUnknownPackageOffline suggestions ->
591+ error "TODO InstallUnknownPackageOffline" suggestions
593+ InstallHasBadDetails _ ->
594+ error "TODO InstallHasBadDetails"
597+{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
598+ Help.report "OLD DEPENDENCIES" (Just "elm.json")
599+ ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
601+ [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
603+ "This may be because it is not upgraded yet. It may be because a\
604+ \ better solution came along, so there was no need to upgrade it.\
605+ \ Etc. Try asking around on Slack to learn more about the topic."
607+ "Whatever the case, please be kind to the relevant package authors! Having\
608+ \ friendly interactions with users is great motivation, and conversely, getting\
609+ \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
610+ \ authors are humans with families, friends, jobs, vacations, responsibilities,\
611+ \ goals, etc. They face obstacles outside of their technical work you will never\
612+ \ know about, so please assume the best and try to be patient and supportive!"
622+ = SolverBadCacheData Pkg.Name V.Version
623+ | SolverBadHttpData Pkg.Name V.Version
624+ | SolverBadHttp Http.Error
632+ = OutlineHasBadStructure (Decode.Error OutlineProblem)
633+ | OutlineHasBadSrcDirs FilePath [FilePath]
638+ | OP_BadPkgName Row Col
639+ | OP_BadVersion Row Col
640+ | OP_BadConstraint C.Error
641+ | OP_BadModuleName Row Col
642+ | OP_BadModuleHeaderTooLong
643+ | OP_BadDependencyName Row Col
644+ | OP_BadLicense Json.String [Json.String]
645+ | OP_BadSummaryTooLong
656+ | DetailsNoOfflineSolution
657+ | DetailsSolverProblem Solver
658+ | DetailsBadElmInPkg C.Constraint
659+ | DetailsBadElmInAppOutline V.Version
660+ | DetailsHandEditedDependencies
661+ | DetailsBadOutline Outline
662+ | DetailsCannotGetRegistry RegistryProblem
663+ | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
667+ = RP_Http Http.Error
672+ = PP_BadEndpointRequest Http.Error
673+ | PP_BadEndpointContent
674+ | PP_BadArchiveRequest Http.Error
675+ | PP_BadArchiveContent
676+ | PP_BadArchiveHash String String
685+ | MakeCannotOptimizeAndDebug
686+ | MakeBlockedByDetailsProblem Details
687+ | MakeAppNeedsFileNames
688+ | MakePkgNeedsExposing
689+ | MakeMultipleFilesIntoHtml
690+ | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
691+ | MakeCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
692+ | MakeCannotBuild BuildProblem
693+ | MakeCannotLoadArtifacts
697+ = BuildModuleProblems Error.Module [Error.Module]
698+ | BuildProjectProblem BuildProjectProblem
701+data BuildProjectProblem
702+ = BP_PathUnknown FilePath
703+ | BP_WithBadExtension FilePath
704+ | BP_WithAmbiguousSrcDir FilePath FilePath
705+ | BP_MainPathDuplicate FilePath FilePath
706+ | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
707+ | BP_CannotLoadDependencies
708+ | BP_Cycle ModuleName.Raw [ModuleName.Raw]
709+ | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
716+toString :: Help.Report -> String
718+ Help.toString (Help.reportToDoc report)
721+toStderr :: Help.Report -> IO ()
723+ Help.toStderr (Help.reportToDoc report)
726+toJson :: Help.Report -> Encode.Value
728+ Help.reportToJson report
722-- DETAILS TO REPORT
732-- DETAILS TO REPORT