git.iko.soy/rowtype-yoga/package-sets
on psc-0.14.0-20210402 help sign in
rowtype-yoga/package-sets/ci/src/GithubIssue.purs
45 lines 1.4 kB history raw
1module GithubIssue (mkIssueContent) where
3import Prelude
4import Data.Array (intercalate)
5import Data.Map (Map)
6import Data.Map as M
7import Data.Tuple (Tuple(..))
8import Github (IssueContent)
9import PackageSets (Package)
10import VersionCompare (VersionComparison)
12-- | Create the content of the github issue shows the current state
13-- | It contains the packages that can be updated
14-- | The state can be 'open' or 'closed' (github api)
15mkIssueContent :: Map Package VersionComparison -> IssueContent
16mkIssueContent packageComparison = { title, body, state }
17 where
18 state = if M.isEmpty packageComparison then "closed" else "open"
20 title = "Version Check: " <> summary
22 summary =
23 if M.isEmpty packageComparison then
24 "All packages up-to-date ✔️"
25 else
26 (show $ M.size packageComparison) <> " package(s) ⚠️"
28 body = intercalate "\n\n" $ [ packages, explainer ]
30 packages =
31 "# Packages\n\n"
32 <> summary
33 <> "\n\n"
34 <> intercalate "\n" packageLines
36 packageLines :: Array String
37 packageLines = do
38 Tuple k v <- M.toUnfoldable packageComparison
39 pure $ "* " <> show k <> " " <> show v
41 explainer =
42 "# About this Issue\n\n"
43 <> "This issue is **updated automatically**. "
44 <> "It can be closed and will be re-opened in case there are new updates available.\n\n"
45 <> "See <https://github.com/purescript/package-sets/tree/master/ci>"