-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuild.fs
132 lines (92 loc) · 3.38 KB
/
Build.fs
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
open Fake.Core
open Fake.IO
open Helpers
initializeContext ()
let sln = "GenPres.sln"
let sharedPath = Path.getFullName "src/Shared"
let serverPath = Path.getFullName "src/Server"
let clientPath = Path.getFullName "src/Client"
let dataPath = Path.getFullName "src/Server/data"
let deployPath = Path.getFullName "deploy"
let clientTestsPath = Path.getFullName "tests/Client"
Target.create
"Clean"
(fun _ ->
Shell.cleanDir deployPath
Shell.cleanDir (Path.combine clientPath "dist")
run dotnet [ "fable"; "clean"; "--yes"; "-e"; ".jsx" ] clientPath // Delete *.fs.js files created by Fable
)
Target.create "RestoreClient" (fun _ -> run npm [ "ci" ] clientPath)
Target.create
"Bundle"
(fun _ ->
[
"server", dotnet [ "publish"; "-c"; "Release"; "-o"; deployPath ] serverPath
"client",
dotnet
[
"fable"
"-o"
"output"
"-s"
"-e"
".jsx"
"--run"
"npx"
"vite"
"build"
"--emptyOutDir"
]
clientPath
]
|> runParallel
let deployDataPath = Path.combine deployPath "data"
printfn $"Copying data to {deployDataPath} ..."
Shell.copyDir deployDataPath dataPath (fun _ -> true)
let result = System.IO.Directory.Exists(deployDataPath)
printfn $"Copying data ... done: {result}"
)
Target.create "Build" (fun _ -> run dotnet [ "build"; sln ] ".")
Target.create
"Run"
(fun _ ->
[
"server", dotnet [ "run"; "--no-restore" ] serverPath
"client",
dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "-e"; ".jsx"; "--run"; "npx"; "vite" ] clientPath
]
|> runParallel
)
Target.create "ServerTests" (fun _ -> run dotnet [ "test"; sln; "--no-build"; "--no-restore" ] ".")
Target.create
"TestHeadless"
(fun _ ->
run dotnet [ "test"; sln; "--no-build"; "--no-restore" ] "."
run dotnet [ "fable"; "-o"; "output"; "-s"; "-e"; ".jsx"; "--run"; "npx"; "vite" ] clientPath
// run dotnet [ "fable"; "-o"; "output"; "-e"; ".jsx" ] clientTestsPath
// run npx [ "mocha"; "output" ] clientTestsPath
)
Target.create
"WatchTests"
(fun _ ->
[
// "server", dotnet [ "watch"; "run"; "--no-restore" ] serverTestsPath
"client",
dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "-e"; ".jsx"; "--run"; "npx"; "vite" ] clientTestsPath
]
|> runParallel
)
Target.create "Format" (fun _ -> run dotnet [ "fantomas"; "." ] ".")
Target.create "DockerRun" (fun _ -> run docker [ "run"; "-it"; "p"; "8080:8085"; "halcwb/genpres"] ".")
Target.create "DockerLinux" (fun _ -> run docker [ "build"; "--platform"; "linux/amd64"; "-t"; "halcwb/genpres"; "."] ".")
Target.create "DockerLocal" (fun _ -> run docker [ "build"; "-t"; "halcwb/genpres"; "."] ".")
open Fake.Core.TargetOperators
let dependencies =
[
"Clean" ==> "RestoreClient" ==> "Bundle"
"Clean" ==> "RestoreClient" ==> "Build" ==> "Run"
"RestoreClient" ==> "Build" ==> "TestHeadless"
"RestoreClient" ==> "Build" ==> "WatchTests"
]
[<EntryPoint>]
let main args = runOrDefault args