@@ -6,11 +6,10 @@ module Reporting.Exit.Publish
66 where
77
88
9−import qualified Text.PrettyPrint.ANSI.Leijen as P
10−import Text.PrettyPrint.ANSI.Leijen ((<>))
11−
129import Deps.Diff (Magnitude, magnitudeToString)
1310import qualified Elm.Package as Pkg
11+import Reporting.Doc ((<>))
12+import qualified Reporting.Doc as D
1413import qualified Reporting.Exit.Help as Help
1514
1615
@@ -46,52 +45,52 @@ toReport exit =
4645
4746 NotInitialVersion vsn ->
4847 Help.docReport "INVALID VERSION" Nothing
49− ( P.fillSep
48+ ( D.fillSep
5049 ["I","cannot","publish"
51− ,P.red (P.text (Pkg.versionToString vsn))
50+ ,D.red (D.fromString (Pkg.versionToString vsn))
5251 ,"as","the","initial","version."
5352 ]
5453 )
55− [ P.fillSep
56− ["Change","it","to",P.green "1.0.0","which","is"
54+ [ D.fillSep
55+ ["Change","it","to",D.green "1.0.0","which","is"
5756 ,"the","initial","version","for","all","Elm","packages."
5857 ]
5958 ]
6059
6160 AlreadyPublished vsn ->
6261 Help.docReport "ALREADY PUBLISHED" Nothing
63− ( P.vcat
64− [ P.fillSep
65− [ "Version", P.green (P.text (Pkg.versionToString vsn))
62+ ( D.vcat
63+ [ D.fillSep
64+ [ "Version", D.green (D.fromString (Pkg.versionToString vsn))
6665 , "has", "already", "been", "published.", "You", "cannot"
6766 , "publish", "it", "again!"
6867 ]
6968 , "Try using the `bump` command:"
7069 ]
7170 )
72− [ P.dullyellow $ P.indent 4 $ P.text "elm bump"
73− , Help.reflow $
71+ [ D.dullyellow $ D.indent 4 "elm bump"
72+ , D.reflow $
7473 "It computes the version number based on API changes, ensuring\
7574 \ that no breaking changes end up in PATCH releases!"
7675 ]
7776
7877 InvalidBump statedVersion latestVersion ->
7978 Help.docReport "INVALID VERSION" (Just "elm.json")
80− ( P.fillSep $
79+ ( D.fillSep $
8180 ["Your","elm.json","says","the","next","version","should","be"
82− ,P.red (P.text (Pkg.versionToString statedVersion)) <> ","
81+ ,D.red (D.fromString (Pkg.versionToString statedVersion)) <> ","
8382 ,"but","that","is","not","valid","based","on","the","previously"
8483 ,"published","versions."
8584 ]
8685 )
87− [ P.fillSep $
86+ [ D.fillSep $
8887 ["Change","the","version","back","to"
89− ,P.green (P.text (Pkg.versionToString latestVersion))
88+ ,D.green (D.fromString (Pkg.versionToString latestVersion))
9089 ,"which","is","the","most","recently","published","version."
9190 ,"From","there,","have","Elm","bump","the","version","by","running:"
9291 ]
93− , P.indent 4 $ P.green "elm bump"
94− , Help.reflow $
92+ , D.indent 4 $ D.green "elm bump"
93+ , D.reflow $
9594 "If you want more insight on the API changes Elm detects, you\
9695 \ can run `elm diff` at this point as well."
9796 ]
@@ -99,51 +98,51 @@ toReport exit =
9998 BadBump old new magnitude realNew realMagnitude ->
10099 Help.docReport "INVALID VERSION" (Just "elm.json")
101100 (
102− P.fillSep $
101+ D.fillSep $
103102 ["Your","elm.json","says","the","next","version","should","be"
104− ,P.red (P.text (Pkg.versionToString new)) <> ","
105− ,"indicating","a",P.text (magnitudeToString magnitude)
103+ ,D.red (D.fromString (Pkg.versionToString new)) <> ","
104+ ,"indicating","a",D.fromString (magnitudeToString magnitude)
106105 ,"change","to","the","public","API."
107106 ,"This","does","not","match","the","API","diff","given","by:"
108107 ]
109108 )
110− [ P.indent 4 $ P.text $
109+ [ D.indent 4 $ D.fromString $
111110 "elm diff " ++ Pkg.versionToString old
112111
113− , P.fillSep $
112+ , D.fillSep $
114113 ["This","command","says","this","is","a"
115− ,P.text (magnitudeToString realMagnitude)
114+ ,D.fromString (magnitudeToString realMagnitude)
116115 ,"change,","so","the","next","version","should","be"
117− ,P.green (P.text (Pkg.versionToString realNew)) <> "."
116+ ,D.green (D.fromString (Pkg.versionToString realNew)) <> "."
118117 ,"Double","check","everything","to","make","sure","you"
119118 ,"are","publishing","what","you","want!"
120119 ]
121− , Help.reflow $
120+ , D.reflow $
122121 "Also, next time use `elm bump` and I'll figure all this out for you!"
123122 ]
124123
125124 NoSummary ->
126125 Help.docReport "NO SUMMARY" (Just "elm.json")
127− ( P.fillSep $
126+ ( D.fillSep $
128127 [ "To", "publish", "a", "package,", "your", "elm.json", "must"
129− , "have", "a", P.dullyellow "\"summary\"", "field", "that", "gives"
128+ , "have", "a", D.dullyellow "\"summary\"", "field", "that", "gives"
130129 , "a", "consice", "overview", "of", "your", "project."
131130 ]
132131 )
133− [ Help.reflow $
132+ [ D.reflow $
134133 "The summary must be less than 80 characters. It should describe\
135134 \ the concrete use of your package as clearly and as plainly as possible."
136135 ]
137136
138137 NoExposed ->
139138 Help.docReport "NO EXPOSED MODULES" (Just "elm.json")
140− ( P.fillSep $
139+ ( D.fillSep $
141140 [ "To", "publish", "a", "package,", "the"
142− , P.dullyellow "\"exposed-modules\"", "field", "of", "your"
141+ , D.dullyellow "\"exposed-modules\"", "field", "of", "your"
143142 , "elm.json", "must", "list", "at", "least", "one", "module."
144143 ]
145144 )
146− [ Help.reflow $
145+ [ D.reflow $
147146 "What is the point of a package that has no modules?!"
148147 ]
149148
@@ -162,7 +161,7 @@ toReport exit =
162161 "By publishing a package you are inviting the Elm community to build\
163162 \ upon your work. But without knowing your license, we have no idea if\
164163 \ that is legal!"
165− [ Help.reflow $
164+ [ D.reflow $
166165 "Once you pick an OSI approved license from <https://spdx.org/licenses/>,\
167166 \ you must share that choice in two places. First, the license\
168167 \ identifier must appear in your elm.json file. Second, the full\
@@ -173,16 +172,16 @@ toReport exit =
173172 MissingTag version ->
174173 let vsn = Pkg.versionToString version in
175174 Help.docReport "NO TAG" Nothing
176− ( P.fillSep $
175+ ( D.fillSep $
177176 [ "Packages", "must", "be", "tagged", "in", "git,", "but", "I"
178− , "cannot", "find", "a", P.green (P.text vsn), "tag."
177+ , "cannot", "find", "a", D.green (D.fromString vsn), "tag."
179178 ]
180179 )
181− [ P.vcat
180+ [ D.vcat
182181 [ "These tags make it possible to find this specific version on GitHub."
183182 , "To tag the most recent commit and push it to GitHub, run this:"
184183 ]
185− , P.indent 4 $ P.dullyellow $ P.vcat $ map P.text $
184+ , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromString $
186185 [ "git tag -a alpha-" ++ vsn ++ " -m \"preparing for Elm 0.19\""
187186 , "git push origin alpha-" ++ vsn
188187 ]
@@ -193,27 +192,27 @@ toReport exit =
193192 Help.report "NO GIT" Nothing
194193 "I searched your PATH environment variable for `git` and could not\
195194 \ find it. Is it available through your PATH?"
196− [ Help.reflow $
195+ [ D.reflow $
197196 "Who cares about this? Well, I currently use `git` to check if there\
198197 \ are any local changes in your code. Local changes are a good sign\
199198 \ that some important improvements have gotten mistagged, so this\
200199 \ check can be extremely helpful for package authors!"
201− , Help.note $
200+ , D.toSimpleNote $
202201 "We plan to do this without the `git` binary in a future release."
203202 ]
204203
205204 LocalChanges version ->
206205 let vsn = Pkg.versionToString version in
207206 Help.docReport "LOCAL CHANGES" Nothing
208− ( P.fillSep $
209− [ "The", "code", "tagged", "as", P.green (P.text vsn), "in"
207+ ( D.fillSep $
208+ [ "The", "code", "tagged", "as", D.green (D.fromString vsn), "in"
210209 , "git", "does", "not", "match", "the", "code", "in", "your"
211210 , "working", "directory.", "This", "means", "you", "have"
212211 , "commits", "or", "local", "changes", "that", "are", "not"
213212 , "going", "to", "be", "published!"
214213 ]
215214 )
216− [ Help.note $
215+ [ D.toSimpleNote $
217216 "If you are sure everything is in order, you can run `git checkout "
218217 ++ vsn ++ "` and publish your code from there."
219218 ]
@@ -222,17 +221,17 @@ toReport exit =
222221badReadmeReport :: String -> String -> Help.Report
223222badReadmeReport title summary =
224223 Help.report title (Just "README.md") summary
225− [ Help.reflow $
224+ [ D.reflow $
226225 "When people look at your README, they are wondering:"
227− , P.vcat
226+ , D.vcat
228227 [ " - What does this package even do?"
229228 , " - Will it help me solve MY problems?"
230229 ]
231− , Help.reflow $
230+ , D.reflow $
232231 "So I recommend starting your README with a small example of the\
233232 \ most common usage scenario. Show people what they can expect if\
234233 \ they learn more!"
235− , Help.note $
234+ , D.toSimpleNote $
236235 "By publishing your package, you are inviting people to invest time\
237236 \ in understanding your work. Spending an hour to communicate your\
238237 \ knowledge more clearly can save the community days or weeks of time\