on bf2e5eb help sign in
elk/builder/src/Reporting/Progress.hs
106 lines 1.8 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Progress
3 ( Reporter(..)
4 , makeReporter
5 , silentReporter
6 , Msg(..)
7 , Progress(..)
8 , Outcome(..)
9 , PublishPhase(..)
10 , BumpPhase(..)
11 )
12 where
15import Control.Concurrent.Chan (Chan, writeChan)
16import Control.Concurrent.MVar (MVar, readMVar)
17import qualified Elm.Compiler.Module as Module
18import Deps.Diff (Magnitude)
19import Elm.Package (Name, Version)
20import Reporting.Exit (Exit)
24-- REPORTER
27data Reporter =
28 Reporter
29 { _tell :: Progress -> IO ()
30 , _end :: Maybe Exit -> IO ()
31 }
34makeReporter :: Chan Msg -> MVar () -> Reporter
35makeReporter chan mvar =
36 let
37 tell progress =
38 writeChan chan (Progress progress)
40 end maybeError =
41 do writeChan chan (End maybeError)
42 readMVar mvar
43 in
44 Reporter tell end
47silentReporter :: Reporter
48silentReporter =
49 Reporter
50 (\_ -> return ())
51 (\_ -> return ())
55-- MESSAGES
58data Msg = Progress Progress | End (Maybe Exit)
61data Progress
62 -- download packages
63 = DownloadSkip
64 | DownloadStart [(Name, Version)]
65 | DownloadPkgStart Name Version
66 | DownloadPkgEnd Name Version Outcome
67 | DownloadEnd Outcome
69 -- build dependencies
70 | BuildDepsStart Int
71 | BuildDepsProgress
72 | BuildDepsEnd
74 -- compile files
75 | CompileStart Int
76 | CompileFileStart Module.Raw
77 | CompileFileEnd Module.Raw Outcome
78 | CompileEnd
80 -- publish
81 | PublishStart Name Version (Maybe [Version])
82 | PublishCheckBump Version BumpPhase
83 | PublishProgress PublishPhase (Maybe Outcome)
84 | PublishEnd
86 -- solver
87 | UnableToLoadLatestPackages
90data Outcome = Good | Bad
93data PublishPhase
94 = CheckReadme
95 | CheckLicense
96 | CheckTag Version
97 | CheckDownload
98 | CheckBuild
99 | CheckChanges
102data BumpPhase
103 = StatedVersion
104 | GoodStart
105 | GoodBump Version Magnitude
106 | BadBump