This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.fsx
167 lines (122 loc) · 4.51 KB
/
build.fsx
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#r @"packages/build/FAKE/tools/FakeLib.dll"
open Fake
open System
open System.IO
let clientPath = "./src/Client" |> FullName
let testsPath = "./src/Domain.Tests" |> FullName
let serverPath = "./src/Server" |> FullName
let supportPath = "./src/Support" |> FullName
let dotnetcliVersion = Fake.DotNetCli.GetDotNetSDKVersionFromGlobalJson()
let mutable dotnetExePath = "dotnet"
// Pattern specifying assemblies to be tested using expecto
// let clientTestExecutables = "test/UITests/**/bin/**/*Tests*.exe"
// --------------------------------------------------------------------------------------
// END TODO: The rest of the file includes standard build steps
// --------------------------------------------------------------------------------------
let run' timeout cmd args dir =
if execProcess (fun info ->
info.FileName <- cmd
if not (String.IsNullOrWhiteSpace dir) then
info.WorkingDirectory <- dir
info.Arguments <- args
) timeout |> not then
failwithf "Error while running '%s' with args: %s" cmd args
let run = run' System.TimeSpan.MaxValue
let runDotnet workingDir args =
let result =
ExecProcess (fun info ->
info.FileName <- dotnetExePath
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
if result <> 0 then failwithf "dotnet %s failed" args
let platformTool tool winTool =
let tool = if isUnix then tool else winTool
tool
|> ProcessHelper.tryFindFileOnPath
|> function Some t -> t | _ -> failwithf "%s not found" tool
let nodeTool = platformTool "node" "node.exe"
let npmTool = platformTool "npm" "npm.cmd"
let yarnTool = platformTool "yarn" "yarn.cmd"
do if not isWindows then
// We have to set the FrameworkPathOverride so that dotnet sdk invocations know
// where to look for full-framework base class libraries
let mono = platformTool "mono" "mono"
let frameworkPath = IO.Path.GetDirectoryName(mono) </> ".." </> "lib" </> "mono" </> "4.5"
setEnvironVar "FrameworkPathOverride" frameworkPath
// --------------------------------------------------------------------------------------
// Clean build results
Target "Clean" (fun _ ->
!!"src/**/bin" ++ "src/**/obj/"
++ "test/**/bin" ++ "test/**/obj/"
|> CleanDirs
CleanDirs ["bin"; "temp"; "docs/output"; Path.Combine(clientPath,"public/bundle")]
)
Target "InstallDotNetCore" (fun _ ->
dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
)
// --------------------------------------------------------------------------------------
// Build library & test project
Target "Restore" (fun _ ->
runDotnet currentDirectory "restore"
)
Target "BuildTests" (fun _ ->
runDotnet testsPath "build"
)
Target "RunTests" (fun _ ->
runDotnet testsPath "test"
)
Target "InstallClient" (fun _ ->
printfn "Node version:"
run nodeTool "--version" __SOURCE_DIRECTORY__
printfn "Yarn version:"
run yarnTool "--version" __SOURCE_DIRECTORY__
run yarnTool "install --frozen-lockfile" __SOURCE_DIRECTORY__
)
Target "BuildClient" (fun _ ->
run yarnTool "webpack --config src/Client/webpack.config.js -p" clientPath
)
Target "RunFixtures" (fun _ ->
runDotnet supportPath "run"
)
// --------------------------------------------------------------------------------------
// Run the Website
let ipAddress = "localhost"
let port = 8080
// FinalTarget "KillProcess" (fun _ ->
// killProcess "dotnet"
// killProcess "dotnet.exe"
// )
Target "Run" (fun _ ->
let suave = async { runDotnet serverPath "run" }
let fablewatch = async {
run yarnTool "webpack-dev-server --config src/Client/webpack.config.js" clientPath
}
let openBrowser = async {
System.Threading.Thread.Sleep(5000)
Diagnostics.Process.Start("http://"+ ipAddress + sprintf ":%d" port) |> ignore }
Async.Parallel [| suave; fablewatch; openBrowser |]
|> Async.RunSynchronously
|> ignore
)
// -------------------------------------------------------------------------------------
Target "Build" DoNothing
Target "All" DoNothing
"Clean"
==> "InstallDotNetCore"
==> "Restore"
==> "InstallClient"
==> "BuildClient"
==> "RunTests"
==> "All"
"BuildClient"
==> "Build"
"InstallClient"
==> "Run"
"BuildTests"
==> "RunTests"
"Restore"
==> "RunFixtures"
RunTargetOrDefault "All"