-
Notifications
You must be signed in to change notification settings - Fork 27
/
generate-stack-yaml.hs
executable file
·106 lines (96 loc) · 2.57 KB
/
generate-stack-yaml.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /usr/bin/env stack
{-
stack runghc
--resolver lts-21.7
--package basic-prelude
--package process
--package yaml
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
import BasicPrelude
import qualified Data.Text as Text
import Data.Yaml.Builder ((.=))
import qualified Data.Yaml.Builder as Yaml
import qualified System.Process as Process
data Dep = Dep
{ name :: Text
, sha :: Text
}
main :: IO ()
main = do
deps <- depsWithShas
Yaml.writeYamlFile "stack.yaml" (mkYamlFile deps)
mkYamlFile :: [Dep] -> Yaml.YamlBuilder
mkYamlFile deps = Yaml.mapping
[ "resolver" .= Yaml.string "lts-21.7"
, "extra-deps" .= Yaml.array (
(map Yaml.string
[ "tuple-0.3.0.2"
, "cubicbezier-0.6.0.6"
, "mfsolve-0.3.2.1"
, "haskell-src-exts-1.23.1"
, "haskell-src-exts-simple-1.23.0.0"
, "fast-math-1.0.2"
, "pandoc-3.1.2"
, "pandoc-types-1.23"
, "SVGFonts-1.8.0.1"
, "hakyll-4.16.0.0"
, "active-0.2.0.17"
, "citeproc-0.8.1"
, "doctemplates-0.11"
, "skylighting-0.13.2.1"
, "skylighting-core-0.13.2.1"
])
++
map mkDepObject deps
)
, "packages" .= Yaml.array [Yaml.string "."]
]
-- : Yaml.mapping
-- [ "location" .= Yaml.mapping
-- [ "git" .= Yaml.string "[email protected]:st3ll1s/haddock.git"
-- , "commit" .= Yaml.string "b3912d70f74b0693f1ea8cffb8f547b1303ef325"
-- ]
-- , "subdirs" .= Yaml.array
-- [ Yaml.string "haddock-library" ]
-- , "extra-dep" .= Yaml.bool True
-- ]
-- : map mkDepObject deps
-- )
{- - location:
git: [email protected]:st3ll1s/haddock.git
commit: b3912d70f74b0693f1ea8cffb8f547b1303ef325
subdirs:
- haddock-library
extra-dep: true
-}
where
mkDepObject :: Dep -> Yaml.YamlBuilder
mkDepObject (Dep name sha) =
Yaml.mapping
[ "git" .= Yaml.string ("https://github.com/diagrams/" <> name)
, "commit" .= Yaml.string sha
]
depsWithShas :: IO [Dep]
depsWithShas =
forM repoNames $ \repoName -> do
[sha, _] <- words . Text.pack <$> Process.readProcess "git" ["ls-remote", textToString $ "[email protected]:diagrams/" <> repoName, "master"] ""
return (Dep repoName sha)
repoNames :: [Text]
repoNames =
[ "diagrams-builder"
, "diagrams-haddock"
, "diagrams-core"
, "diagrams-lib"
, "diagrams-rasterific"
, "diagrams-svg"
, "diagrams-solve"
, "diagrams-contrib"
, "docutils"
, "dual-tree"
, "monoid-extras"
, "force-layout"
, "palette"
, "svg-builder"
]