on 42f3721 help sign in
82 lines 3.4 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit.Install
3 ( Exit(..)
4 , toReport
5 )
6 where
9import qualified Elm.Compiler as Compiler
10import qualified Elm.Package as Pkg
11import qualified Reporting.Doc as D
12import qualified Reporting.Exit.Help as Help
16-- EXITS
19data Exit
20 = NoArgs FilePath
21 | NoSolution [Pkg.Name]
25-- TO REPORT
28toReport :: Exit -> Help.Report
29toReport exit =
30 case exit of
31 NoArgs elmHome ->
32 Help.report "INSTALL WHAT?" Nothing
33 "I am expecting commands like:"
34 [ D.green $ D.indent 4 $ D.vcat $
35 [ "elm install elm/http"
36 , "elm install elm/json"
37 , "elm install elm/random"
38 ]
39 , D.toFancyHint
40 ["In","JavaScript","folks","run","`npm install`","to","start","projects."
41 ,"\"Gotta","download","everything!\"","But","why","download","packages"
42 ,"again","and","again?","Instead,","Elm","caches","packages","in"
43 ,D.dullyellow (D.fromString elmHome)
44 ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
45 ,"Elm","projects","check","that","cache","before","trying","the","internet."
46 ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
47 ,"easier","to","work","offline.","As","a","result"
48 ,D.dullcyan "elm install","is","only","for","adding","dependencies","to","elm.json,"
49 ,"whereas",D.dullcyan "elm make","is","in","charge","of","gathering","dependencies"
50 ,"and","building","everything.","So","maybe","try",D.green "elm make","instead?"
51 ]
52 ]
54 NoSolution badPackages ->
55 case badPackages of
56 [] ->
57 Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json")
58 "This usually happens if you try to modify dependency constraints by\
59 \ hand. I recommend deleting any dependency you added recently (or all\
60 \ of them if things are bad) and then adding them again with:"
61 [ D.indent 4 $ D.green "elm install"
62 , D.reflow $
63 "And do not be afaid to ask for help on Slack if you get stuck!"
64 ]
66 _:_ ->
67 Help.report "OLD DEPENDENCIES" (Just "elm.json")
68 ( "The following packages do not work with Elm " ++ Pkg.versionToString Compiler.version ++ " right now:"
69 )
70 [ D.indent 4 $ D.vcat $ map (D.red . D.fromString . Pkg.toString) badPackages
71 , D.reflow $
72 "This may be because it is not upgraded yet. It may be because a\
73 \ better solution came along, so there was no need to upgrade it.\
74 \ Etc. Try asking around on Slack to learn more about the topic."
75 , D.toSimpleNote
76 "Whatever the case, please be kind to the relevant package authors! Having\
77 \ friendly interactions with users is great motivation, and conversely, getting\
78 \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
79 \ authors are humans with families, friends, jobs, vacations, responsibilities,\
80 \ goals, etc. They face obstacles outside of their technical work you will never\
81 \ know about, so please assume the best and try to be patient and supportive!"
82 ]