@@ -6,11 +6,10 @@ module Reporting.Exit.Publish
9−import qualified Text.PrettyPrint.ANSI.Leijen as P
10−import Text.PrettyPrint.ANSI.Leijen ((<>))
12import Deps.Diff (Magnitude, magnitudeToString)
9import Deps.Diff (Magnitude, magnitudeToString)
13import qualified Elm.Package as Pkg
10import qualified Elm.Package as Pkg
11+import Reporting.Doc ((<>))
12+import qualified Reporting.Doc as D
14import qualified Reporting.Exit.Help as Help
13import qualified Reporting.Exit.Help as Help
@@ -46,52 +45,52 @@ toReport exit =
47 NotInitialVersion vsn ->
46 NotInitialVersion vsn ->
48 Help.docReport "INVALID VERSION" Nothing
47 Help.docReport "INVALID VERSION" Nothing
49− ( P.fillSep
48+ ( D.fillSep
50 ["I","cannot","publish"
49 ["I","cannot","publish"
51− ,P.red (P.text (Pkg.versionToString vsn))
50+ ,D.red (D.fromString (Pkg.versionToString vsn))
52 ,"as","the","initial","version."
51 ,"as","the","initial","version."
55− [ P.fillSep
54+ [ D.fillSep
56− ["Change","it","to",P.green "1.0.0","which","is"
55+ ["Change","it","to",D.green "1.0.0","which","is"
57 ,"the","initial","version","for","all","Elm","packages."
56 ,"the","initial","version","for","all","Elm","packages."
61 AlreadyPublished vsn ->
60 AlreadyPublished vsn ->
62 Help.docReport "ALREADY PUBLISHED" Nothing
61 Help.docReport "ALREADY PUBLISHED" Nothing
64− [ P.fillSep
63+ [ D.fillSep
65− [ "Version", P.green (P.text (Pkg.versionToString vsn))
64+ [ "Version", D.green (D.fromString (Pkg.versionToString vsn))
66 , "has", "already", "been", "published.", "You", "cannot"
65 , "has", "already", "been", "published.", "You", "cannot"
67 , "publish", "it", "again!"
66 , "publish", "it", "again!"
69 , "Try using the `bump` command:"
68 , "Try using the `bump` command:"
72− [ P.dullyellow $ P.indent 4 $ P.text "elm bump"
71+ [ D.dullyellow $ D.indent 4 "elm bump"
73− , Help.reflow $
72+ , D.reflow $
74 "It computes the version number based on API changes, ensuring\
73 "It computes the version number based on API changes, ensuring\
75 \ that no breaking changes end up in PATCH releases!"
74 \ that no breaking changes end up in PATCH releases!"
78 InvalidBump statedVersion latestVersion ->
77 InvalidBump statedVersion latestVersion ->
79 Help.docReport "INVALID VERSION" (Just "elm.json")
78 Help.docReport "INVALID VERSION" (Just "elm.json")
80− ( P.fillSep $
79+ ( D.fillSep $
81 ["Your","elm.json","says","the","next","version","should","be"
80 ["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)) <> ","
83 ,"but","that","is","not","valid","based","on","the","previously"
82 ,"but","that","is","not","valid","based","on","the","previously"
84 ,"published","versions."
83 ,"published","versions."
87− [ P.fillSep $
86+ [ D.fillSep $
88 ["Change","the","version","back","to"
87 ["Change","the","version","back","to"
89− ,P.green (P.text (Pkg.versionToString latestVersion))
88+ ,D.green (D.fromString (Pkg.versionToString latestVersion))
90 ,"which","is","the","most","recently","published","version."
89 ,"which","is","the","most","recently","published","version."
91 ,"From","there,","have","Elm","bump","the","version","by","running:"
90 ,"From","there,","have","Elm","bump","the","version","by","running:"
93− , P.indent 4 $ P.green "elm bump"
92+ , D.indent 4 $ D.green "elm bump"
94− , Help.reflow $
93+ , D.reflow $
95 "If you want more insight on the API changes Elm detects, you\
94 "If you want more insight on the API changes Elm detects, you\
96 \ can run `elm diff` at this point as well."
95 \ can run `elm diff` at this point as well."
@@ -99,51 +98,51 @@ toReport exit =
99 BadBump old new magnitude realNew realMagnitude ->
98 BadBump old new magnitude realNew realMagnitude ->
100 Help.docReport "INVALID VERSION" (Just "elm.json")
99 Help.docReport "INVALID VERSION" (Just "elm.json")
102− P.fillSep $
101+ D.fillSep $
103 ["Your","elm.json","says","the","next","version","should","be"
102 ["Your","elm.json","says","the","next","version","should","be"
104− ,P.red (P.text (Pkg.versionToString new)) <> ","
103+ ,D.red (D.fromString (Pkg.versionToString new)) <> ","
105− ,"indicating","a",P.text (magnitudeToString magnitude)
104+ ,"indicating","a",D.fromString (magnitudeToString magnitude)
106 ,"change","to","the","public","API."
105 ,"change","to","the","public","API."
107 ,"This","does","not","match","the","API","diff","given","by:"
106 ,"This","does","not","match","the","API","diff","given","by:"
110− [ P.indent 4 $ P.text $
109+ [ D.indent 4 $ D.fromString $
111 "elm diff " ++ Pkg.versionToString old
110 "elm diff " ++ Pkg.versionToString old
113− , P.fillSep $
112+ , D.fillSep $
114 ["This","command","says","this","is","a"
113 ["This","command","says","this","is","a"
115− ,P.text (magnitudeToString realMagnitude)
114+ ,D.fromString (magnitudeToString realMagnitude)
116 ,"change,","so","the","next","version","should","be"
115 ,"change,","so","the","next","version","should","be"
117− ,P.green (P.text (Pkg.versionToString realNew)) <> "."
116+ ,D.green (D.fromString (Pkg.versionToString realNew)) <> "."
118 ,"Double","check","everything","to","make","sure","you"
117 ,"Double","check","everything","to","make","sure","you"
119 ,"are","publishing","what","you","want!"
118 ,"are","publishing","what","you","want!"
121− , Help.reflow $
120+ , D.reflow $
122 "Also, next time use `elm bump` and I'll figure all this out for you!"
121 "Also, next time use `elm bump` and I'll figure all this out for you!"
125 NoSummary ->
124 NoSummary ->
126 Help.docReport "NO SUMMARY" (Just "elm.json")
125 Help.docReport "NO SUMMARY" (Just "elm.json")
127− ( P.fillSep $
126+ ( D.fillSep $
128 [ "To", "publish", "a", "package,", "your", "elm.json", "must"
127 [ "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"
130 , "a", "consice", "overview", "of", "your", "project."
129 , "a", "consice", "overview", "of", "your", "project."
133− [ Help.reflow $
132+ [ D.reflow $
134 "The summary must be less than 80 characters. It should describe\
133 "The summary must be less than 80 characters. It should describe\
135 \ the concrete use of your package as clearly and as plainly as possible."
134 \ the concrete use of your package as clearly and as plainly as possible."
138 NoExposed ->
137 NoExposed ->
139 Help.docReport "NO EXPOSED MODULES" (Just "elm.json")
138 Help.docReport "NO EXPOSED MODULES" (Just "elm.json")
140− ( P.fillSep $
139+ ( D.fillSep $
141 [ "To", "publish", "a", "package,", "the"
140 [ "To", "publish", "a", "package,", "the"
142− , P.dullyellow "\"exposed-modules\"", "field", "of", "your"
141+ , D.dullyellow "\"exposed-modules\"", "field", "of", "your"
143 , "elm.json", "must", "list", "at", "least", "one", "module."
142 , "elm.json", "must", "list", "at", "least", "one", "module."
146− [ Help.reflow $
145+ [ D.reflow $
147 "What is the point of a package that has no modules?!"
146 "What is the point of a package that has no modules?!"
@@ -162,7 +161,7 @@ toReport exit =
162 "By publishing a package you are inviting the Elm community to build\
161 "By publishing a package you are inviting the Elm community to build\
163 \ upon your work. But without knowing your license, we have no idea if\
162 \ upon your work. But without knowing your license, we have no idea if\
164 \ that is legal!"
163 \ that is legal!"
165− [ Help.reflow $
164+ [ D.reflow $
166 "Once you pick an OSI approved license from <https://spdx.org/licenses/>,\
165 "Once you pick an OSI approved license from <https://spdx.org/licenses/>,\
167 \ you must share that choice in two places. First, the license\
166 \ you must share that choice in two places. First, the license\
168 \ identifier must appear in your elm.json file. Second, the full\
167 \ identifier must appear in your elm.json file. Second, the full\
@@ -173,16 +172,16 @@ toReport exit =
173 MissingTag version ->
172 MissingTag version ->
174 let vsn = Pkg.versionToString version in
173 let vsn = Pkg.versionToString version in
175 Help.docReport "NO TAG" Nothing
174 Help.docReport "NO TAG" Nothing
176− ( P.fillSep $
175+ ( D.fillSep $
177 [ "Packages", "must", "be", "tagged", "in", "git,", "but", "I"
176 [ "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."
181− [ P.vcat
180+ [ D.vcat
182 [ "These tags make it possible to find this specific version on GitHub."
181 [ "These tags make it possible to find this specific version on GitHub."
183 , "To tag the most recent commit and push it to GitHub, run this:"
182 , "To tag the most recent commit and push it to GitHub, run this:"
185− , P.indent 4 $ P.dullyellow $ P.vcat $ map P.text $
184+ , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromString $
186 [ "git tag -a alpha-" ++ vsn ++ " -m \"preparing for Elm 0.19\""
185 [ "git tag -a alpha-" ++ vsn ++ " -m \"preparing for Elm 0.19\""
187 , "git push origin alpha-" ++ vsn
186 , "git push origin alpha-" ++ vsn
@@ -193,27 +192,27 @@ toReport exit =
193 Help.report "NO GIT" Nothing
192 Help.report "NO GIT" Nothing
194 "I searched your PATH environment variable for `git` and could not\
193 "I searched your PATH environment variable for `git` and could not\
195 \ find it. Is it available through your PATH?"
194 \ find it. Is it available through your PATH?"
196− [ Help.reflow $
195+ [ D.reflow $
197 "Who cares about this? Well, I currently use `git` to check if there\
196 "Who cares about this? Well, I currently use `git` to check if there\
198 \ are any local changes in your code. Local changes are a good sign\
197 \ are any local changes in your code. Local changes are a good sign\
199 \ that some important improvements have gotten mistagged, so this\
198 \ that some important improvements have gotten mistagged, so this\
200 \ check can be extremely helpful for package authors!"
199 \ check can be extremely helpful for package authors!"
201− , Help.note $
200+ , D.toSimpleNote $
202 "We plan to do this without the `git` binary in a future release."
201 "We plan to do this without the `git` binary in a future release."
205 LocalChanges version ->
204 LocalChanges version ->
206 let vsn = Pkg.versionToString version in
205 let vsn = Pkg.versionToString version in
207 Help.docReport "LOCAL CHANGES" Nothing
206 Help.docReport "LOCAL CHANGES" Nothing
208− ( P.fillSep $
207+ ( D.fillSep $
209− [ "The", "code", "tagged", "as", P.green (P.text vsn), "in"
208+ [ "The", "code", "tagged", "as", D.green (D.fromString vsn), "in"
210 , "git", "does", "not", "match", "the", "code", "in", "your"
209 , "git", "does", "not", "match", "the", "code", "in", "your"
211 , "working", "directory.", "This", "means", "you", "have"
210 , "working", "directory.", "This", "means", "you", "have"
212 , "commits", "or", "local", "changes", "that", "are", "not"
211 , "commits", "or", "local", "changes", "that", "are", "not"
213 , "going", "to", "be", "published!"
212 , "going", "to", "be", "published!"
216− [ Help.note $
215+ [ D.toSimpleNote $
217 "If you are sure everything is in order, you can run `git checkout "
216 "If you are sure everything is in order, you can run `git checkout "
218 ++ vsn ++ "` and publish your code from there."
217 ++ vsn ++ "` and publish your code from there."
@@ -222,17 +221,17 @@ toReport exit =
222badReadmeReport :: String -> String -> Help.Report
221badReadmeReport :: String -> String -> Help.Report
223badReadmeReport title summary =
222badReadmeReport title summary =
224 Help.report title (Just "README.md") summary
223 Help.report title (Just "README.md") summary
225− [ Help.reflow $
224+ [ D.reflow $
226 "When people look at your README, they are wondering:"
225 "When people look at your README, they are wondering:"
227− , P.vcat
226+ , D.vcat
228 [ " - What does this package even do?"
227 [ " - What does this package even do?"
229 , " - Will it help me solve MY problems?"
228 , " - Will it help me solve MY problems?"
231− , Help.reflow $
230+ , D.reflow $
232 "So I recommend starting your README with a small example of the\
231 "So I recommend starting your README with a small example of the\
233 \ most common usage scenario. Show people what they can expect if\
232 \ most common usage scenario. Show people what they can expect if\
234 \ they learn more!"
233 \ they learn more!"
235− , Help.note $
234+ , D.toSimpleNote $
236 "By publishing your package, you are inviting people to invest time\
235 "By publishing your package, you are inviting people to invest time\
237 \ in understanding your work. Spending an hour to communicate your\
236 \ in understanding your work. Spending an hour to communicate your\
238 \ knowledge more clearly can save the community days or weeks of time\
237 \ knowledge more clearly can save the community days or weeks of time\