on master help sign in
Continue centralizing errors into Reporting.Exit module
8cd5c29Evan Czaplicki
builder/src/Reporting/Exit.hs+689−67
@@ -1,6 +1,28 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit
2module Reporting.Exit
3 ( Exit(..)
3 ( Exit(..)
4+ --
5+ , Init(..)
6+ , initToReport
7+ --
8+ , Diff(..)
9+ , diffToReport
10+ --
11+ , Install(..)
12+ , installToReport
13+ --
14+ , Details(..)
15+ , OutlineProblem(..)
16+ , OutlineStructureProblem(..)
17+ , RegistryProblem(..)
18+ , PackageProblem(..)
19+ --
20+ , Make(..)
21+ , BuildProblem(..)
22+ , BuildProjectProblem(..)
23+ , makeToReport
24+ --
25+ , DocsProblem(..)
4 , toString
26 , toString
5 , toStderr
27 , toStderr
6 , toJson
28 , toJson
@@ -8,21 +30,21 @@ module Reporting.Exit
8 where
30 where
9
31
10
32
33+import qualified Data.List as List
34+import qualified Data.Utf8 as Utf8
35+
36+import qualified Elm.Constraint as C
37+import qualified Elm.Magnitude as M
11import qualified Elm.ModuleName as ModuleName
38import qualified Elm.ModuleName as ModuleName
39+import qualified Elm.Package as Pkg
40+import qualified Elm.Version as V
41+import qualified Http
12import qualified Json.Encode as Encode
42import qualified Json.Encode as Encode
43+import Reporting.Doc ((<>))
13import qualified Reporting.Doc as D
44import qualified Reporting.Doc as D
14−import qualified Reporting.Exit.Assets as Asset
45+import qualified Reporting.Error.Json as Json
15−import qualified Reporting.Exit.Bump as Bump
16−import qualified Reporting.Exit.Compile as Compile
17−import qualified Reporting.Exit.Crawl as Crawl
18−import qualified Reporting.Exit.Deps as Deps
19−import qualified Reporting.Exit.Diff as Diff
20import qualified Reporting.Exit.Help as Help
46import qualified Reporting.Exit.Help as Help
21−import qualified Reporting.Exit.Http as Http
47+import qualified Reporting.Problem as Problem
22−import qualified Reporting.Exit.Make as Make
23−import qualified Reporting.Exit.Init as Init
24−import qualified Reporting.Exit.Install as Install
25−import qualified Reporting.Exit.Publish as Publish
26
48
27
49
28
50
@@ -30,44 +52,605 @@ import qualified Reporting.Exit.Publish as Publish
30
52
31
53
32data Exit
54data Exit
33− = NoElmJson
55+ -- bump
34− | Assets Asset.Exit
56+ = BumpApplication
35− | Bump Bump.Exit
57+ | BumpUnexpectedVersion V.Version [V.Version]
36− | Compile Compile.Exit [Compile.Exit]
58+ | BumpMustHaveLatestRegistry RegistryProblem
37− | Crawl Crawl.Exit
59+ | BumpCannotFindDocs Pkg.Name V.Version DocsProblem
38− | Cycle [ModuleName.Raw] -- TODO write docs to help with this scenario
60+ -- publish
39− | Deps Deps.Exit
61+ | PublishMustHaveLatestRegistry RegistryProblem
40− | Diff Diff.Exit
62+ | PublishApplication
63+ | PublishNotInitialVersion V.Version
64+ | PublishAlreadyPublished V.Version
65+ | PublishInvalidBump V.Version V.Version
66+ | PublishBadBump V.Version V.Version M.Magnitude V.Version M.Magnitude
67+ | PublishNoSummary
68+ | PublishNoExposed
69+ | PublishNoReadme
70+ | PublishShortReadme
71+ | PublishNoLicense
72+ | PublishCannotGetTag Http.Error
73+ | PublishCannotGetZip Http.Error
74+ | PublishCannotDecodeZip
75+ | PublishCannotGetDocs DocsProblem
76+ | PublishCannotRegister Http.Error
77+ | PublishMissingTag V.Version
78+ | PublishNoGit
79+ | PublishLocalChanges V.Version
80+
81+
82+data DocsProblem
83+ = DP_Http Http.Error
84+ | DP_Data
85+ | DP_Cache
86+
87+
88+
89+-- INIT
90+
91+
92+data Init
93+ = InitNoSolution [Pkg.Name]
94+ | InitAlreadyExists
95+ | InitRegistryProblem RegistryProblem
96+
97+
98+initToReport :: Init -> Help.Report
99+initToReport exit =
100+ case exit of
101+ InitNoSolution pkgs ->
102+ Help.report "NO SOLUTION" Nothing
103+ "I tried to create an elm.json with the following direct dependencies:"
104+ [ D.indent 4 $ D.vcat $
105+ map (D.dullyellow . D.fromChars . Pkg.toChars) pkgs
106+ , D.reflow $
107+ "I could not find compatible versions though! This should not happen, so please\
108+ \ ask around one of the community forums at https://elm-lang.org/community to learn\
109+ \ what is going on!"
110+ ]
111+
112+ InitAlreadyExists ->
113+ Help.report "EXISTING PROJECT" Nothing
114+ "You already have an elm.json file, so there is nothing for me to initialize!"
115+ [ D.fillSep
116+ ["Maybe",D.green (D.fromChars (D.makeLink "init")),"can","help"
117+ ,"you","figure","out","what","to","do","next?"
118+ ]
119+ ]
120+
121+ InitRegistryProblem _ ->
122+ error "TODO InitRegistryProblem"
123+
124+
125+
126+-- DIFF
127+
128+
129+data Diff
130+ = DiffApplication
131+ | DiffUnpublished
132+ | DiffUnknownPackage Pkg.Name [Pkg.Name]
133+ | DiffUnknownVersion Pkg.Name V.Version [V.Version]
134+ | DiffCannotFindDocs DocsProblem
135+ | DiffMustHaveLatestRegistry RegistryProblem
136+
137+
138+diffToReport :: Diff -> Help.Report
139+diffToReport diff =
140+ case diff of
141+ DiffApplication ->
142+ Help.report "CANNOT DIFF APPLICATIONS" Nothing
143+ "I cannot perform diffs on applications, only packages! If you are\
144+ \ just curious to see a diff, try running this command:"
145+ [ D.indent 4 $ D.green $ "elm diff elm/html 5.1.1 6.0.0"
146+ ]
147+
148+ DiffUnpublished ->
149+ Help.report "UNPUBLISHED" Nothing
150+ "This package is not published yet. There is nothing to diff against!"
151+ []
152+
153+ DiffUnknownPackage pkg suggestions ->
154+ Help.report "UNKNOWN PACKAGE" Nothing
155+ ( "I cannot find a package called:"
156+ )
157+ [ D.indent 4 $ D.red $ D.fromUtf8 $ Pkg.toString pkg
158+ , "Maybe you want one of these instead?"
159+ , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromUtf8 . Pkg.toString) suggestions
160+ , "But check <https://package.elm-lang.org> to see all possibilities!"
161+ ]
162+
163+ DiffUnknownVersion _pkg vsn realVersions ->
164+ Help.docReport "UNKNOWN VERSION" Nothing
165+ ( D.fillSep $
166+ [ "Version", D.red (D.fromUtf8 (V.toString vsn))
167+ , "has", "never", "been", "published,", "so", "I"
168+ , "cannot", "diff", "against", "it."
169+ ]
170+ )
171+ [ "Here are all the versions that HAVE been published:"
172+ , D.indent 4 $ D.dullyellow $ D.vcat $
173+ let
174+ sameMajor v1 v2 = V._major v1 == V._major v2
175+ mkRow vsns = D.hsep $ map (D.fromUtf8 . V.toString) vsns
176+ in
177+ map mkRow $ List.groupBy sameMajor (List.sort realVersions)
178+ , "Want one of those instead?"
179+ ]
180+
181+ DiffCannotFindDocs problem ->
182+ error "TODO DiffCannotFindDocs" problem
183+
184+ DiffMustHaveLatestRegistry problem ->
185+ error "TODO DiffMustHaveLatestRegistry" problem
186+
187+
188+
189+-- INSTALL
190+
191+
192+data Install
193+ = InstallNoArgs FilePath
194+ | InstallNoSolution [Pkg.Name]
195+
196+
197+installToReport :: Install -> Help.Report
198+installToReport exit =
199+ case exit of
200+ InstallNoArgs elmHome ->
201+ Help.report "INSTALL WHAT?" Nothing
202+ "I am expecting commands like:"
203+ [ D.green $ D.indent 4 $ D.vcat $
204+ [ "elm install elm/http"
205+ , "elm install elm/json"
206+ , "elm install elm/random"
207+ ]
208+ , D.toFancyHint
209+ ["In","JavaScript","folks","run","`npm install`","to","start","projects."
210+ ,"\"Gotta","download","everything!\"","But","why","download","packages"
211+ ,"again","and","again?","Instead,","Elm","caches","packages","in"
212+ ,D.dullyellow (D.fromChars elmHome)
213+ ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
214+ ,"Elm","projects","check","that","cache","before","trying","the","internet."
215+ ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
216+ ,"easier","to","work","offline.","As","a","result"
217+ ,D.dullcyan "elm install","is","only","for","adding","dependencies","to","elm.json,"
218+ ,"whereas",D.dullcyan "elm make","is","in","charge","of","gathering","dependencies"
219+ ,"and","building","everything.","So","maybe","try",D.green "elm make","instead?"
220+ ]
221+ ]
222+
223+ InstallNoSolution badPackages ->
224+ case badPackages of
225+ [] ->
226+ Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO give better advice!
227+ "This usually happens if you try to modify dependency constraints by\
228+ \ hand. I recommend deleting any dependency you added recently (or all\
229+ \ of them if things are bad) and then adding them again with:"
230+ [ D.indent 4 $ D.green "elm install"
231+ , D.reflow $
232+ "And do not be afaid to ask for help on Slack if you get stuck!"
233+ ]
234+
235+ _:_ ->
236+ Help.report "OLD DEPENDENCIES" (Just "elm.json")
237+ ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
238+ )
239+ [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
240+ , D.reflow $
241+ "This may be because it is not upgraded yet. It may be because a\
242+ \ better solution came along, so there was no need to upgrade it.\
243+ \ Etc. Try asking around on Slack to learn more about the topic."
244+ , D.toSimpleNote
245+ "Whatever the case, please be kind to the relevant package authors! Having\
246+ \ friendly interactions with users is great motivation, and conversely, getting\
247+ \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
248+ \ authors are humans with families, friends, jobs, vacations, responsibilities,\
249+ \ goals, etc. They face obstacles outside of their technical work you will never\
250+ \ know about, so please assume the best and try to be patient and supportive!"
251+ ]
252+
253+
254+
255+-- DETAILS
256+
257+
258+data Details
259+ = DetailsCorrupt
260+ | DetailsBadElmInPkg C.Constraint
261+ | DetailsBadElmInAppOutline V.Version
262+ | DetailsHandEditedDependencies
263+ | DetailsBadOutline OutlineProblem
264+ | DetailsCannotGetRegistry RegistryProblem
265+ | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
266+
267+
268+data OutlineProblem
269+ = BadOutlineStructure (Json.Error OutlineStructureProblem)
270+ | BadOutlineSrcDirs FilePath [FilePath]
271+
272+
273+data OutlineStructureProblem
274+ = OSP_BadType Utf8.String
275+ | OSP_BadPkgName Pkg.BadName
276+ | OSP_BadVersion Utf8.String
277+ | OSP_BadConstraint C.Error
278+ | OSP_BadModuleName Utf8.String
279+ | OSP_BadModuleHeaderTooLong Utf8.String
280+ | OSP_BadDependencyName Utf8.String
281+ | OSP_BadLicense Utf8.String [Utf8.String]
282+ | OSP_BadSummaryTooLong
283+
284+
285+data RegistryProblem
286+ = RP_Http Http.Error
287+ | RP_Data
288+
289+
290+data PackageProblem
291+ = PP_BadEndpointRequest Http.Error
292+ | PP_BadEndpointContent
293+ | PP_BadArchiveRequest Http.Error
294+ | PP_BadArchiveContent
295+ | PP_BadArchiveHash String String
296+
297+
298+
299+-- MAKE
300+
301+
41− | Make Make.Exit
302+data Make
42− | Init Init.Exit
303+ = MakeNeedsOutline
43− | Install Install.Exit
304+ | MakeCannotOptimizeAndDebug
44− | Publish Publish.Exit
305+ | MakeBlockedByDetailsProblem Details
45− | BadHttp String Http.Exit
306+ | MakeAppNeedsFileNames
307+ | MakePkgNeedsExposing
308+ | MakeMultipleFilesIntoHtml
309+ | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
310+ | MakeCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
311+ | MakeCannotBuild BuildProblem
312+ | MakeCannotLoadArtifacts
313+
314+
315+data BuildProblem
316+ = BuildModuleProblems Problem.Problem [Problem.Problem]
317+ | BuildProjectProblem BuildProjectProblem
318+
319+
320+data BuildProjectProblem
321+ = BP_PathUnknown FilePath
322+ | BP_WithBadExtension FilePath
323+ | BP_WithAmbiguousSrcDir FilePath FilePath
324+ | BP_MainPathDuplicate FilePath FilePath
325+ | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
326+ | BP_CannotLoadDependencies
327+ | BP_Cycle ModuleName.Raw [ModuleName.Raw]
46
328
47
329
48
330
49-- RENDERERS
331-- RENDERERS
50
332
51
333
52−toString :: Exit -> String
334+toString :: Help.Report -> String
53−toString exit =
335+toString report =
54− Help.toString (Help.reportToDoc (toReport exit))
336+ Help.toString (Help.reportToDoc report)
55
337
56
338
57−toStderr :: Exit -> IO ()
339+toStderr :: Help.Report -> IO ()
58−toStderr exit =
340+toStderr report =
59− Help.toStderr (Help.reportToDoc (toReport exit))
341+ Help.toStderr (Help.reportToDoc report)
60
342
61
343
62−toJson :: Exit -> Encode.Value
344+toJson :: Help.Report -> Encode.Value
63−toJson exit =
345+toJson report =
64− Help.reportToJson (toReport exit)
346+ Help.reportToJson report
65
347
66
348
67−toReport :: Exit -> Help.Report
349+_toReport :: Exit -> Help.Report
68−toReport exit =
350+_toReport exit =
69 case exit of
351 case exit of
70− NoElmJson ->
352+
353+ -- bump
354+
355+ BumpApplication ->
356+ Help.report "CANNOT BUMP APPLICATIONS" (Just "elm.json")
357+ "Your elm.json says this is an application. That means it cannot be published\
358+ \ on <https://package.elm-lang.org> and therefore has no version to bump!"
359+ []
360+
361+ BumpUnexpectedVersion vsn versions ->
362+ Help.docReport "CANNOT BUMP" (Just "elm.json")
363+ ( D.fillSep
364+ ["Your","elm.json","says","I","should","bump","relative","to","version"
365+ ,D.red (D.fromUtf8 (V.toString vsn)) <> ","
366+ ,"but","I","cannot","find","that","version","on","<https://package.elm-lang.org>."
367+ ,"That","means","there","is","no","API","for","me","to","diff","against","and"
368+ ,"figure","out","if","these","are","MAJOR,","MINOR,","or","PATCH","changes."
369+ ]
370+ )
371+ [ D.fillSep $
372+ ["Try","bumping","again","after","changing","the",D.dullyellow "\"version\"","in","elm.json"]
373+ ++ if length versions == 1 then ["to:"] else ["to","one","of","these:"]
374+ , D.vcat $ map (D.green . D.fromUtf8 . V.toString) versions
375+ ]
376+
377+ BumpMustHaveLatestRegistry problem ->
378+ error "TODO BumpMustHaveLatestRegistry" problem
379+
380+ BumpCannotFindDocs name version problem ->
381+ error "TODO BumpCannotFindDocs" name version problem
382+
383+ -- publish
384+
385+ PublishMustHaveLatestRegistry problem ->
386+ error "TODO PublishMustHaveLatestRegistry" problem
387+
388+ PublishApplication ->
389+ Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" []
390+
391+ PublishNotInitialVersion vsn ->
392+ Help.docReport "INVALID VERSION" Nothing
393+ ( D.fillSep
394+ ["I","cannot","publish"
395+ ,D.red (D.fromUtf8 (V.toString vsn))
396+ ,"as","the","initial","version."
397+ ]
398+ )
399+ [ D.fillSep
400+ ["Change","it","to",D.green "1.0.0","which","is"
401+ ,"the","initial","version","for","all","Elm","packages."
402+ ]
403+ ]
404+
405+ PublishAlreadyPublished vsn ->
406+ Help.docReport "ALREADY PUBLISHED" Nothing
407+ ( D.vcat
408+ [ D.fillSep
409+ [ "Version", D.green (D.fromUtf8 (V.toString vsn))
410+ , "has", "already", "been", "published.", "You", "cannot"
411+ , "publish", "it", "again!"
412+ ]
413+ , "Try using the `bump` command:"
414+ ]
415+ )
416+ [ D.dullyellow $ D.indent 4 "elm bump"
417+ , D.reflow $
418+ "It computes the version number based on API changes, ensuring\
419+ \ that no breaking changes end up in PATCH releases!"
420+ ]
421+
422+ PublishInvalidBump statedVersion latestVersion ->
423+ Help.docReport "INVALID VERSION" (Just "elm.json")
424+ ( D.fillSep $
425+ ["Your","elm.json","says","the","next","version","should","be"
426+ ,D.red (D.fromUtf8 (V.toString statedVersion)) <> ","
427+ ,"but","that","is","not","valid","based","on","the","previously"
428+ ,"published","versions."
429+ ]
430+ )
431+ [ D.fillSep $
432+ ["Change","the","version","back","to"
433+ ,D.green (D.fromUtf8 (V.toString latestVersion))
434+ ,"which","is","the","most","recently","published","version."
435+ ,"From","there,","have","Elm","bump","the","version","by","running:"
436+ ]
437+ , D.indent 4 $ D.green "elm bump"
438+ , D.reflow $
439+ "If you want more insight on the API changes Elm detects, you\
440+ \ can run `elm diff` at this point as well."
441+ ]
442+
443+ PublishBadBump old new magnitude realNew realMagnitude ->
444+ Help.docReport "INVALID VERSION" (Just "elm.json")
445+ (
446+ D.fillSep $
447+ ["Your","elm.json","says","the","next","version","should","be"
448+ ,D.red (D.fromUtf8 (V.toString new)) <> ","
449+ ,"indicating","a",D.fromChars (M.toChars magnitude)
450+ ,"change","to","the","public","API."
451+ ,"This","does","not","match","the","API","diff","given","by:"
452+ ]
453+ )
454+ [ D.indent 4 $ D.fromChars $
455+ "elm diff " ++ V.toChars old
456+
457+ , D.fillSep $
458+ ["This","command","says","this","is","a"
459+ ,D.fromChars (M.toChars realMagnitude)
460+ ,"change,","so","the","next","version","should","be"
461+ ,D.green (D.fromUtf8 (V.toString realNew)) <> "."
462+ ,"Double","check","everything","to","make","sure","you"
463+ ,"are","publishing","what","you","want!"
464+ ]
465+ , D.reflow $
466+ "Also, next time use `elm bump` and I'll figure all this out for you!"
467+ ]
468+
469+ PublishNoSummary ->
470+ Help.docReport "NO SUMMARY" (Just "elm.json")
471+ ( D.fillSep $
472+ [ "To", "publish", "a", "package,", "your", "elm.json", "must"
473+ , "have", "a", D.dullyellow "\"summary\"", "field", "that", "gives"
474+ , "a", "consice", "overview", "of", "your", "project."
475+ ]
476+ )
477+ [ D.reflow $
478+ "The summary must be less than 80 characters. It should describe\
479+ \ the concrete use of your package as clearly and as plainly as possible."
480+ ]
481+
482+ PublishNoExposed ->
483+ Help.docReport "NO EXPOSED MODULES" (Just "elm.json")
484+ ( D.fillSep $
485+ [ "To", "publish", "a", "package,", "the"
486+ , D.dullyellow "\"exposed-modules\"", "field", "of", "your"
487+ , "elm.json", "must", "list", "at", "least", "one", "module."
488+ ]
489+ )
490+ [ D.reflow $
491+ "What is the point of a package that has no modules?!"
492+ ]
493+
494+ PublishNoReadme ->
495+ badReadmeReport "NO README" $
496+ "Every published package must have a helpful README.md\
497+ \ file, but I do not see one in your project."
498+
499+ PublishShortReadme ->
500+ badReadmeReport "SHORT README" $
501+ "This README.md is too short. Having more details will help\
502+ \ people assess your package quickly and fairly."
503+
504+ PublishNoLicense ->
505+ Help.report "NO LICENSE FILE" (Just "LICENSE")
506+ "By publishing a package you are inviting the Elm community to build\
507+ \ upon your work. But without knowing your license, we have no idea if\
508+ \ that is legal!"
509+ [ D.reflow $
510+ "Once you pick an OSI approved license from <https://spdx.org/licenses/>,\
511+ \ you must share that choice in two places. First, the license\
512+ \ identifier must appear in your elm.json file. Second, the full\
513+ \ license text must appear in the root of your project in a file\
514+ \ named LICENSE. Add that file and you will be all set!"
515+ ]
516+
517+ PublishCannotGetTag httpError ->
518+ error "TODO PublishCannotGetTag" httpError
519+
520+ PublishCannotGetZip httpError ->
521+ error "TODO PublishCannotGetZip" httpError
522+
523+ PublishCannotDecodeZip ->
524+ error "TODO PublishCannotDecodeZip"
525+
526+ PublishCannotGetDocs docsProblem ->
527+ error "TODO PublishCannotGetDocs" docsProblem
528+
529+ PublishCannotRegister httpError ->
530+ error "TODO PublishCannotRegister" httpError
531+
532+ PublishMissingTag version ->
533+ let vsn = V.toChars version in
534+ Help.docReport "NO TAG" Nothing
535+ ( D.fillSep $
536+ [ "Packages", "must", "be", "tagged", "in", "git,", "but", "I"
537+ , "cannot", "find", "a", D.green (D.fromChars vsn), "tag."
538+ ]
539+ )
540+ [ D.vcat
541+ [ "These tags make it possible to find this specific version on GitHub."
542+ , "To tag the most recent commit and push it to GitHub, run this:"
543+ ]
544+ , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromChars $
545+ [ "git tag -a " ++ vsn ++ " -m \"new release\""
546+ , "git push origin " ++ vsn
547+ ]
548+ , "The -m flag is for a helpful message. Try to make it more informative!"
549+ ]
550+
551+ PublishNoGit ->
552+ Help.report "NO GIT" Nothing
553+ "I searched your PATH environment variable for `git` and could not\
554+ \ find it. Is it available through your PATH?"
555+ [ D.reflow $
556+ "Who cares about this? Well, I currently use `git` to check if there\
557+ \ are any local changes in your code. Local changes are a good sign\
558+ \ that some important improvements have gotten mistagged, so this\
559+ \ check can be extremely helpful for package authors!"
560+ , D.toSimpleNote $
561+ "We plan to do this without the `git` binary in a future release."
562+ ]
563+
564+ PublishLocalChanges version ->
565+ let vsn = V.toChars version in
566+ Help.docReport "LOCAL CHANGES" Nothing
567+ ( D.fillSep $
568+ [ "The", "code", "tagged", "as", D.green (D.fromChars vsn), "in"
569+ , "git", "does", "not", "match", "the", "code", "in", "your"
570+ , "working", "directory.", "This", "means", "you", "have"
571+ , "commits", "or", "local", "changes", "that", "are", "not"
572+ , "going", "to", "be", "published!"
573+ ]
574+ )
575+ [ D.toSimpleNote $
576+ "If you are sure everything is in order, you can run `git checkout "
577+ ++ vsn ++ "` and publish your code from there."
578+ ]
579+
580+
581+badReadmeReport :: String -> String -> Help.Report
582+badReadmeReport title summary =
583+ Help.report title (Just "README.md") summary
584+ [ D.reflow $
585+ "When people look at your README, they are wondering:"
586+ , D.vcat
587+ [ " - What does this package even do?"
588+ , " - Will it help me solve MY problems?"
589+ ]
590+ , D.reflow $
591+ "So I recommend starting your README with a small example of the\
592+ \ most common usage scenario. Show people what they can expect if\
593+ \ they learn more!"
594+ , D.toSimpleNote $
595+ "By publishing your package, you are inviting people to invest time\
596+ \ in understanding your work. Spending an hour to communicate your\
597+ \ knowledge more clearly can save the community days or weeks of time\
598+ \ in aggregate, and saving time in aggregate is the whole point of\
599+ \ publishing packages! People really appreciate it, and it makes the\
600+ \ whole ecosystem feel nicer!"
601+ ]
602+
603+
604+
605+-- DETAILS TO REPORT
606+
607+
608+detailsToReport :: Details -> Help.Report
609+detailsToReport details =
610+ case details of
611+ DetailsCorrupt ->
612+ error "TODO DetailsCorrupt"
613+
614+ DetailsBadElmInPkg constraint ->
615+ Help.report "ELM VERSION MISMATCH" (Just "elm.json")
616+ "Your elm.json says this package needs a version of Elm in this range:"
617+ [ D.indent 4 $ D.dullyellow $ D.fromUtf8 $ C.toString constraint
618+ , D.fillSep
619+ [ "But", "you", "are", "using", "Elm"
620+ , D.red (D.fromUtf8 (V.toString V.compiler))
621+ , "right", "now."
622+ ]
623+ ]
624+
625+ DetailsBadElmInAppOutline version ->
626+ Help.report "ELM VERSION MISMATCH" (Just "elm.json")
627+ "Your elm.json says this application needs a different version of Elm."
628+ [ D.fillSep
629+ [ "It", "requires"
630+ , D.green (D.fromUtf8 (V.toString version)) <> ","
631+ , "but", "you", "are", "using"
632+ , D.red (D.fromUtf8 (V.toString V.compiler))
633+ , "right", "now."
634+ ]
635+ ]
636+
637+ DetailsHandEditedDependencies ->
638+ error "TODO DetailsHandEditedDependencies"
639+
640+ DetailsBadOutline problem ->
641+ error "TODO DetailsBadOutline" problem
642+
643+ DetailsCannotGetRegistry problem ->
644+ error "TODO DetailsCannotGetRegistry" problem
645+
646+ DetailsCannotBuildPackage name version problem ->
647+ error "TODO DetailsCannotBuildPackage" name version problem
648+
649+
650+makeToReport :: Make -> Help.Report
651+makeToReport make =
652+ case make of
653+ MakeNeedsOutline ->
71 Help.report "NO elm.json FILE" Nothing
654 Help.report "NO elm.json FILE" Nothing
72 "It looks like you are starting a new Elm project. Very exciting! Try running:"
655 "It looks like you are starting a new Elm project. Very exciting! Try running:"
73 [ D.indent 4 $ D.green $ "elm init"
656 [ D.indent 4 $ D.green $ "elm init"
@@ -75,44 +658,83 @@ toReport exit =
75 "It will help you get set up. It is really simple!"
658 "It will help you get set up. It is really simple!"
76 ]
659 ]
77
660
78− Assets assetExit ->
661+ MakeCannotOptimizeAndDebug ->
79− Asset.toReport assetExit
662+ Help.docReport "CLASHING FLAGS" Nothing
80−
663+ ( D.fillSep
81− Bump bumpExit ->
664+ ["I","cannot","compile","with",D.red "--optimize","and"
82− Bump.toReport bumpExit
665+ ,D.red "--debug","at","the","same","time."
83−
666+ ]
84− Compile e es ->
667+ )
85− Help.compilerReport e es
668+ [ D.reflow
669+ "I need to take away information to optimize things, and I need to\
670+ \ add information to add the debugger. It is impossible to do both\
671+ \ at once though! Pick just one of those flags and it should work!"
672+ ]
86
673
87− Crawl crawlExit ->
674+ MakeBlockedByDetailsProblem detailsProblem ->
88− Crawl.toReport crawlExit
675+ detailsToReport detailsProblem
89
676
90− Cycle names ->
677+ MakeAppNeedsFileNames ->
91− Help.report "IMPORT CYCLE" Nothing
678+ Help.report "NO INPUT" Nothing
92− "Your module imports form a cycle:"
679+ "What should I make though? I need a specific file like this:"
93− [ D.cycle 4 names
680+ [ D.indent 4 $ D.green "elm make src/Main.elm"
94− , D.reflow $
681+ , D.reflow
95− "Learn more about why this is disallowed and how to break cycles here:"
682+ "However many files you give, I will create one JS file out of them."
96− ++ D.makeLink "import-cycles"
97 ]
683 ]
98
684
99− Deps depsExit ->
685+ MakePkgNeedsExposing ->
100− Deps.toReport depsExit
686+ error "TODO MakePkgNeedsExposing"
687+
688+ MakeMultipleFilesIntoHtml ->
689+ error "TODO MakeMultipleFilesIntoHtml"
101
690
102− Diff commandsExit ->
691+ MakeNonMainFilesIntoJavaScript _ _ ->
103− Diff.toReport commandsExit
692+ error "TODO MakeNonMainFilesIntoJavaScript"
104
693
105− Make makeExit ->
694+ MakeCannotOptimizeDebugValues m ms ->
106− Make.toReport makeExit
695+ Help.report "DEBUG REMNANTS" Nothing
696+ "There are uses of the `Debug` module in the following modules:"
697+ [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.toChars) (m:ms)
698+ , D.reflow "But the --optimize flag only works if all `Debug` functions are removed!"
699+ , D.toSimpleNote $
700+ "The issue is that --optimize strips out info needed by `Debug` functions.\
701+ \ Here are two examples:"
702+ , D.indent 4 $ D.reflow $
703+ "(1) It shortens record field names. This makes the generated JavaScript is\
704+ \ smaller, but `Debug.toString` cannot know the real field names anymore."
705+ , D.indent 4 $ D.reflow $
706+ "(2) Values like `type Height = Height Float` are unboxed. This reduces\
707+ \ allocation, but it also means that `Debug.toString` cannot tell if it is\
708+ \ looking at a `Height` or `Float` value."
709+ , D.reflow $
710+ "There are a few other cases like that, and it will be much worse once we start\
711+ \ inlining code. That optimization could move `Debug.log` and `Debug.todo` calls,\
712+ \ resulting in unpredictable behavior. I hope that clarifies why this restriction\
713+ \ exists!"
714+ ]
107
715
108− Init initExit ->
716+ MakeCannotBuild buildProblem ->
109− Init.toReport initExit
717+ case buildProblem of
718+ BuildProjectProblem bp ->
719+ case bp of
720+ BP_PathUnknown _ -> error "TODO BP_PathUnknown"
721+ BP_WithBadExtension _ -> error "TODO BP_WithBadExtension"
722+ BP_WithAmbiguousSrcDir _ _ -> error "TODO BP_WithAmbiguousSrcDir"
723+ BP_MainPathDuplicate _ _ -> error "TODO BP_MainPathDuplicate"
724+ BP_MainNameDuplicate _ _ _ -> error "TODO BP_MainNameDuplicate"
725+ BP_CannotLoadDependencies -> error "TODO BP_CannotLoadDependencies"
726+ BP_Cycle name names ->
727+ Help.report "IMPORT CYCLE" Nothing
728+ "Your module imports form a cycle:"
729+ [ D.cycle 4 name names
730+ , D.reflow $
731+ "Learn more about why this is disallowed and how to break cycles here:"
732+ ++ D.makeLink "import-cycles"
733+ ]
110
734
111− Install installExit ->
112− Install.toReport installExit
113
735
114− Publish publishExit ->
736+ BuildModuleProblems p ps ->
115− Publish.toReport publishExit
737+ error "TODO MakeCannotBuild" p ps
116
738
117− BadHttp url httpExit ->
739+ MakeCannotLoadArtifacts ->
118− Http.toReport url httpExit
740+ error "TODO MakeCannotLoadArtifacts"
builder/src/Reporting/Exit/Bump.hsdeleted−51
@@ -1,51 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Reporting.Exit.Bump
3− ( Exit(..)
4− , toReport
5− )
6− where
7−
8−
9−import qualified Elm.Version as V
10−import Reporting.Doc ((<>))
11−import qualified Reporting.Doc as D
12−import qualified Reporting.Exit.Help as Help
13−
14−
15−
16−-- EXITS
17−
18−
19−data Exit
20− = Application
21− | Unbumpable V.Version [V.Version]
22−
23−
24−
25−-- TO REPORT
26−
27−
28−toReport :: Exit -> Help.Report
29−toReport exit =
30− case exit of
31− Application ->
32− Help.report "UNBUMPABLE" (Just "elm.json")
33− "Your elm.json says this is an application. That means it cannot be published\
34− \ on <https://package.elm-lang.org> and therefore has no version to bump!"
35− []
36−
37− Unbumpable vsn versions ->
38− Help.docReport "UNBUMPABLE" (Just "elm.json")
39− ( D.fillSep
40− ["Your","elm.json","says","I","should","bump","relative","to","version"
41− ,D.red (D.fromUtf8 (V.toString vsn)) <> ","
42− ,"but","I","cannot","find","that","version","on","<https://package.elm-lang.org>."
43− ,"That","means","there","is","no","API","for","me","to","diff","against","and"
44− ,"figure","out","if","these","are","MAJOR,","MINOR,","or","PATCH","changes."
45− ]
46− )
47− [ D.fillSep $
48− ["Try","bumping","again","after","changing","the",D.dullyellow "\"version\"","in","elm.json"]
49− ++ if length versions == 1 then ["to:"] else ["to","one","of","these:"]
50− , D.vcat $ map (D.green . D.fromUtf8 . V.toString) versions
51− ]
builder/src/Reporting/Exit/Diff.hsdeleted−73
@@ -1,73 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Reporting.Exit.Diff
3− ( Exit(..)
4− , toReport
5− )
6− where
7−
8−
9−import qualified Data.List as List
10−
11−import qualified Elm.Package as Pkg
12−import qualified Elm.Version as V
13−import qualified Reporting.Doc as D
14−import qualified Reporting.Exit.Help as Help
15−
16−
17−
18−-- EXITS
19−
20−
21−data Exit
22− = Application
23− | Unpublished
24− | UnknownPackage Pkg.Name [Pkg.Name]
25− | UnknownVersion Pkg.Name V.Version [V.Version]
26−
27−
28−
29−-- TO DOC
30−
31−
32−toReport :: Exit -> Help.Report
33−toReport exit =
34− case exit of
35− Application ->
36− Help.report "CANNOT DIFF APPLICATIONS" Nothing
37− "I cannot perform diffs on applications, only packages! If you are\
38− \ just curious to see a diff, try running this command:"
39− [ D.indent 4 $ D.green $ "elm diff elm/html 5.1.1 6.0.0"
40− ]
41−
42− Unpublished ->
43− Help.report "UNPUBLISHED" Nothing
44− "This package is not published yet. There is nothing to diff against!"
45− []
46−
47− UnknownPackage pkg suggestions ->
48− Help.report "UNKNOWN PACKAGE" Nothing
49− ( "I cannot find a package called:"
50− )
51− [ D.indent 4 $ D.red $ D.fromUtf8 $ Pkg.toString pkg
52− , "Maybe you want one of these instead?"
53− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromUtf8 . Pkg.toString) suggestions
54− , "But check <https://package.elm-lang.org> to see all possibilities!"
55− ]
56−
57− UnknownVersion _pkg vsn realVersions ->
58− Help.docReport "UNKNOWN VERSION" Nothing
59− ( D.fillSep $
60− [ "Version", D.red (D.fromUtf8 (V.toString vsn))
61− , "has", "never", "been", "published,", "so", "I"
62− , "cannot", "diff", "against", "it."
63− ]
64− )
65− [ "Here are all the versions that HAVE been published:"
66− , D.indent 4 $ D.dullyellow $ D.vcat $
67− let
68− sameMajor v1 v2 = V._major v1 == V._major v2
69− mkRow vsns = D.hsep $ map (D.fromUtf8 . V.toString) vsns
70− in
71− map mkRow $ List.groupBy sameMajor (List.sort realVersions)
72− , "Want one of those instead?"
73− ]
builder/src/Reporting/Exit/Init.hsdeleted−48
@@ -1,48 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Reporting.Exit.Init
3− ( Exit(..)
4− , toReport
5− )
6− where
7−
8−
9−import qualified Elm.Package as Pkg
10−import qualified Reporting.Doc as D
11−import qualified Reporting.Exit.Help as Help
12−
13−
14−
15−-- EXITS
16−
17−
18−data Exit
19− = NoSolution [Pkg.Name]
20− | AlreadyStarted
21−
22−
23−
24−-- TO REPORT
25−
26−
27−toReport :: Exit -> Help.Report
28−toReport exit =
29− case exit of
30− NoSolution pkgs ->
31− Help.report "NO SOLUTION" Nothing
32− "I tried to create an elm.json with the following direct dependencies:"
33− [ D.indent 4 $ D.vcat $
34− map (D.dullyellow . D.fromChars . Pkg.toChars) pkgs
35− , D.reflow $
36− "I could not find compatible versions though! This should not happen, so please\
37− \ ask around one of the community forums <http://elm-lang.org/community> to learn\
38− \ what is going on!"
39− ]
40−
41− AlreadyStarted ->
42− Help.report "EXISTING PROJECT" Nothing
43− "You already have an elm.json file, so there is nothing for me to initialize!"
44− [ D.fillSep
45− ["Maybe",D.green (D.fromChars (D.makeLink "init")),"can","help"
46− ,"you","figure","out","what","to","do","next?"
47− ]
48− ]
builder/src/Reporting/Exit/Install.hsdeleted−82
@@ -1,82 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Reporting.Exit.Install
3− ( Exit(..)
4− , toReport
5− )
6− where
7−
8−
9−import qualified Elm.Package as Pkg
10−import qualified Elm.Version as V
11−import qualified Reporting.Doc as D
12−import qualified Reporting.Exit.Help as Help
13−
14−
15−
16−-- EXITS
17−
18−
19−data Exit
20− = NoArgs FilePath
21− | NoSolution [Pkg.Name]
22−
23−
24−
25−-- TO REPORT
26−
27−
28−toReport :: Exit -> Help.Report
29−toReport 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.fromChars 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− ]
53−
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− ]
65−
66− _:_ ->
67− Help.report "OLD DEPENDENCIES" (Just "elm.json")
68− ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
69− )
70− [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . 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− ]
builder/src/Reporting/Exit/Make.hsdeleted−75
@@ -1,75 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Reporting.Exit.Make
3− ( Exit(..)
4− , toReport
5− )
6− where
7−
8−
9−import qualified Elm.ModuleName as ModuleName
10−import qualified Reporting.Doc as D
11−import qualified Reporting.Exit.Help as Help
12−
13−
14−
15−-- EXITS
16−
17−
18−data Exit
19− = CannotMakeNothing
20− | CannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
21− | CannotOptimizeAndDebug
22−
23−
24−
25−-- TO REPORT
26−
27−
28−toReport :: Exit -> Help.Report
29−toReport exit =
30− case exit of
31− CannotMakeNothing ->
32− Help.report "NO INPUT" Nothing
33− "What should I make though? I need more information, like:"
34− [ D.vcat
35− [ D.indent 4 $ D.green "elm make src/Main.elm"
36− , D.indent 4 $ D.green "elm make src/This.elm src/That.elm"
37− ]
38− , D.reflow
39− "However many files you give, I will create one JS file out of them."
40− ]
41−
42− CannotOptimizeDebugValues m ms ->
43− Help.report "DEBUG REMNANTS" Nothing
44− "There are uses of the `Debug` module in the following modules:"
45− [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.nameToChars) (m:ms)
46− , D.reflow "But the --optimize flag only works if all `Debug` functions are removed!"
47− , D.toSimpleNote $
48− "The issue is that --optimize strips out info needed by `Debug` functions.\
49− \ Here are two examples:"
50− , D.indent 4 $ D.reflow $
51− "(1) It shortens record field names. This makes the generated JavaScript is\
52− \ smaller, but `Debug.toString` cannot know the real field names anymore."
53− , D.indent 4 $ D.reflow $
54− "(2) Values like `type Height = Height Float` are unboxed. This reduces\
55− \ allocation, but it also means that `Debug.toString` cannot tell if it is\
56− \ looking at a `Height` or `Float` value."
57− , D.reflow $
58− "There are a few other cases like that, and it will be much worse once we start\
59− \ inlining code. That optimization could move `Debug.log` and `Debug.todo` calls,\
60− \ resulting in unpredictable behavior. I hope that clarifies why this restriction\
61− \ exists!"
62− ]
63−
64− CannotOptimizeAndDebug ->
65− Help.docReport "CLASHING FLAGS" Nothing
66− ( D.fillSep
67− ["I","cannot","compile","with",D.red "--optimize","and"
68− ,D.red "--debug","at","the","same","time."
69− ]
70− )
71− [ D.reflow
72− "I need to take away information to optimize things, and I need to\
73− \ add information to add the debugger. It is impossible to do both\
74− \ at once, so pick just one of those flags."
75− ]
builder/src/Reporting/Exit/Publish.hsdeleted−241
@@ -1,241 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Reporting.Exit.Publish
3− ( Exit(..)
4− , toReport
5− )
6− where
7−
8−
9−import Deps.Diff (Magnitude, magnitudeToString)
10−import qualified Elm.Version as V
11−import Reporting.Doc ((<>))
12−import qualified Reporting.Doc as D
13−import qualified Reporting.Exit.Help as Help
14−
15−
16−
17−-- EXITS
18−
19−
20−data Exit
21− = Application
22− | NotInitialVersion V.Version
23− | AlreadyPublished V.Version
24− | InvalidBump V.Version V.Version
25− | BadBump V.Version V.Version Magnitude V.Version Magnitude
26− | NoSummary
27− | NoExposed
28− | NoReadme
29− | ShortReadme
30− | NoLicense
31− | MissingTag V.Version
32− | NoGit
33− | LocalChanges V.Version
34−
35−
36−
37−-- TO REPORT
38−
39−
40−toReport :: Exit -> Help.Report
41−toReport exit =
42− case exit of
43− Application ->
44− Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" []
45−
46− NotInitialVersion vsn ->
47− Help.docReport "INVALID VERSION" Nothing
48− ( D.fillSep
49− ["I","cannot","publish"
50− ,D.red (D.fromUtf8 (V.toString vsn))
51− ,"as","the","initial","version."
52− ]
53− )
54− [ D.fillSep
55− ["Change","it","to",D.green "1.0.0","which","is"
56− ,"the","initial","version","for","all","Elm","packages."
57− ]
58− ]
59−
60− AlreadyPublished vsn ->
61− Help.docReport "ALREADY PUBLISHED" Nothing
62− ( D.vcat
63− [ D.fillSep
64− [ "Version", D.green (D.fromUtf8 (V.toString vsn))
65− , "has", "already", "been", "published.", "You", "cannot"
66− , "publish", "it", "again!"
67− ]
68− , "Try using the `bump` command:"
69− ]
70− )
71− [ D.dullyellow $ D.indent 4 "elm bump"
72− , D.reflow $
73− "It computes the version number based on API changes, ensuring\
74− \ that no breaking changes end up in PATCH releases!"
75− ]
76−
77− InvalidBump statedVersion latestVersion ->
78− Help.docReport "INVALID VERSION" (Just "elm.json")
79− ( D.fillSep $
80− ["Your","elm.json","says","the","next","version","should","be"
81− ,D.red (D.fromUtf8 (V.toString statedVersion)) <> ","
82− ,"but","that","is","not","valid","based","on","the","previously"
83− ,"published","versions."
84− ]
85− )
86− [ D.fillSep $
87− ["Change","the","version","back","to"
88− ,D.green (D.fromUtf8 (V.toString latestVersion))
89− ,"which","is","the","most","recently","published","version."
90− ,"From","there,","have","Elm","bump","the","version","by","running:"
91− ]
92− , D.indent 4 $ D.green "elm bump"
93− , D.reflow $
94− "If you want more insight on the API changes Elm detects, you\
95− \ can run `elm diff` at this point as well."
96− ]
97−
98− BadBump old new magnitude realNew realMagnitude ->
99− Help.docReport "INVALID VERSION" (Just "elm.json")
100− (
101− D.fillSep $
102− ["Your","elm.json","says","the","next","version","should","be"
103− ,D.red (D.fromUtf8 (V.toString new)) <> ","
104− ,"indicating","a",D.fromChars (magnitudeToString magnitude)
105− ,"change","to","the","public","API."
106− ,"This","does","not","match","the","API","diff","given","by:"
107− ]
108− )
109− [ D.indent 4 $ D.fromChars $
110− "elm diff " ++ V.toChars old
111−
112− , D.fillSep $
113− ["This","command","says","this","is","a"
114− ,D.fromChars (magnitudeToString realMagnitude)
115− ,"change,","so","the","next","version","should","be"
116− ,D.green (D.fromUtf8 (V.toString realNew)) <> "."
117− ,"Double","check","everything","to","make","sure","you"
118− ,"are","publishing","what","you","want!"
119− ]
120− , D.reflow $
121− "Also, next time use `elm bump` and I'll figure all this out for you!"
122− ]
123−
124− NoSummary ->
125− Help.docReport "NO SUMMARY" (Just "elm.json")
126− ( D.fillSep $
127− [ "To", "publish", "a", "package,", "your", "elm.json", "must"
128− , "have", "a", D.dullyellow "\"summary\"", "field", "that", "gives"
129− , "a", "consice", "overview", "of", "your", "project."
130− ]
131− )
132− [ D.reflow $
133− "The summary must be less than 80 characters. It should describe\
134− \ the concrete use of your package as clearly and as plainly as possible."
135− ]
136−
137− NoExposed ->
138− Help.docReport "NO EXPOSED MODULES" (Just "elm.json")
139− ( D.fillSep $
140− [ "To", "publish", "a", "package,", "the"
141− , D.dullyellow "\"exposed-modules\"", "field", "of", "your"
142− , "elm.json", "must", "list", "at", "least", "one", "module."
143− ]
144− )
145− [ D.reflow $
146− "What is the point of a package that has no modules?!"
147− ]
148−
149− NoReadme ->
150− badReadmeReport "NO README" $
151− "Every published package must have a helpful README.md\
152− \ file, but I do not see one in your project."
153−
154− ShortReadme ->
155− badReadmeReport "SHORT README" $
156− "This README.md is too short. Having more details will help\
157− \ people assess your package quickly and fairly."
158−
159− NoLicense ->
160− Help.report "NO LICENSE FILE" (Just "LICENSE")
161− "By publishing a package you are inviting the Elm community to build\
162− \ upon your work. But without knowing your license, we have no idea if\
163− \ that is legal!"
164− [ D.reflow $
165− "Once you pick an OSI approved license from <https://spdx.org/licenses/>,\
166− \ you must share that choice in two places. First, the license\
167− \ identifier must appear in your elm.json file. Second, the full\
168− \ license text must appear in the root of your project in a file\
169− \ named LICENSE. Add that file and you will be all set!"
170− ]
171−
172− MissingTag version ->
173− let vsn = V.toChars version in
174− Help.docReport "NO TAG" Nothing
175− ( D.fillSep $
176− [ "Packages", "must", "be", "tagged", "in", "git,", "but", "I"
177− , "cannot", "find", "a", D.green (D.fromChars vsn), "tag."
178− ]
179− )
180− [ D.vcat
181− [ "These tags make it possible to find this specific version on GitHub."
182− , "To tag the most recent commit and push it to GitHub, run this:"
183− ]
184− , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromChars $
185− [ "git tag -a " ++ vsn ++ " -m \"new release\""
186− , "git push origin " ++ vsn
187− ]
188− , "The -m flag is for a helpful message. Try to make it more informative!"
189− ]
190−
191− NoGit ->
192− Help.report "NO GIT" Nothing
193− "I searched your PATH environment variable for `git` and could not\
194− \ find it. Is it available through your PATH?"
195− [ D.reflow $
196− "Who cares about this? Well, I currently use `git` to check if there\
197− \ are any local changes in your code. Local changes are a good sign\
198− \ that some important improvements have gotten mistagged, so this\
199− \ check can be extremely helpful for package authors!"
200− , D.toSimpleNote $
201− "We plan to do this without the `git` binary in a future release."
202− ]
203−
204− LocalChanges version ->
205− let vsn = V.toChars version in
206− Help.docReport "LOCAL CHANGES" Nothing
207− ( D.fillSep $
208− [ "The", "code", "tagged", "as", D.green (D.fromChars vsn), "in"
209− , "git", "does", "not", "match", "the", "code", "in", "your"
210− , "working", "directory.", "This", "means", "you", "have"
211− , "commits", "or", "local", "changes", "that", "are", "not"
212− , "going", "to", "be", "published!"
213− ]
214− )
215− [ D.toSimpleNote $
216− "If you are sure everything is in order, you can run `git checkout "
217− ++ vsn ++ "` and publish your code from there."
218− ]
219−
220−
221−badReadmeReport :: String -> String -> Help.Report
222−badReadmeReport title summary =
223− Help.report title (Just "README.md") summary
224− [ D.reflow $
225− "When people look at your README, they are wondering:"
226− , D.vcat
227− [ " - What does this package even do?"
228− , " - Will it help me solve MY problems?"
229− ]
230− , D.reflow $
231− "So I recommend starting your README with a small example of the\
232− \ most common usage scenario. Show people what they can expect if\
233− \ they learn more!"
234− , D.toSimpleNote $
235− "By publishing your package, you are inviting people to invest time\
236− \ in understanding your work. Spending an hour to communicate your\
237− \ knowledge more clearly can save the community days or weeks of time\
238− \ in aggregate, and saving time in aggregate is the whole point of\
239− \ publishing packages! People really appreciate it, and it makes the\
240− \ whole ecosystem feel nicer!"
241− ]