-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshake.hs
50 lines (42 loc) · 2.49 KB
/
shake.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
import Development.Shake
import Development.Shake.Cabal
import Development.Shake.Clean
import Development.Shake.ClosureCompiler
import System.Directory
import qualified System.IO.Strict as Strict
main :: IO ()
main = shakeArgs shakeOptions { shakeFiles = ".shake", shakeLint = Just LintBasic } $ do
want [ "target/index.html", "README.md" ]
"deploy" ~> do
need [ "target/index.html", "target/all.min.js" ]
cmd ["ion", "-c", "cp target/* ~/programming/rust/nessa-site/static/{{ project }}"]
"clean" ~> do
cleanHaskell
removeFilesAfter "target" ["//*"]
removeFilesAfter ".shake" ["//*"]
"README.md" %> \out -> do
hs <- getDirectoryFiles "" ["src//*.hs"]
yaml <- getDirectoryFiles "" ["//*.yaml"]
cabal <- getDirectoryFiles "" ["//*.cabal"]
mad <- getDirectoryFiles "" ["//*.mad"]
html <- getDirectoryFiles "" ["web-src//*.html"]
css <- getDirectoryFiles "" ["web-src//*.css"]
need $ hs <> yaml <> cabal <> mad <> html <> css
(Stdout out') <- cmd ["poly", "-c", ".", "-e", "README.md", "-e", "TODO.md", "-e", "target", "-e", "Justfile"]
file <- liftIO $ Strict.readFile out
let header = takeWhile (/= replicate 79 '-') $ lines file
let new = unlines header ++ out' ++ "```\n"
liftIO $ writeFile out new
"dist-newstyle/build/x86_64-linux/ghcjs-0.2.1.9008011/{{ project }}-0.1.0.0/x/{{ project }}/opt/build/{{ project }}/{{ project }}.jsexe/all.js" %> \_ -> do
need . snd =<< getCabalDepsA "{{ project }}.cabal"
-- check the {{ project }}.mad file so we don't push anything wrong
unit $ cmd ["bash", "-c", "madlang check mad-src/{{ project }}.mad > /dev/null"]
command [RemEnv "GHC_PACKAGE_PATH"] "cabal" ["new-build"]
googleClosureCompiler ["dist-newstyle/build/x86_64-linux/ghcjs-0.2.1.9008011/{{ project }}-0.1.0.0/x/{{ project }}/opt/build/{{ project }}/{{ project }}.jsexe/all.js", "dist-newstyle/build/x86_64-linux/ghcjs-0.2.1.9008011/{{ project }}-0.1.0.0/x/{{ project }}/opt/build/{{ project }}/{{ project }}.jsexe/all.js"] "target/all.min.js"
"target/styles.css" %> \out -> do
liftIO $ createDirectoryIfMissing True "target"
need ["web-src/styles.css"]
copyFile' "web-src/styles.css" out
"target/index.html" %> \out -> do
need ["target/all.min.js", "web-src/index.html", "target/styles.css"]
copyFile' "web-src/index.html" out