-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.fsx
127 lines (99 loc) · 3.13 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
#r @"packages/build/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
let libPath = "./src"
let testsPath = "./test"
let samplePath = "./sample"
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 = "node"
let mutable dotnetCli = "dotnet"
let run fileName args workingDir =
printfn "CWD: %s" workingDir
let fileName, args =
if isUnix
then fileName, args else "cmd", ("/C " + fileName + " " + args)
let ok =
execProcess (fun info ->
info.FileName <- fileName
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
if not ok then failwith (sprintf "'%s> %s %s' task failed" workingDir fileName args)
let delete file =
if File.Exists(file)
then DeleteFile file
else ()
let cleanBundles() =
Path.Combine("public", "bundle.js")
|> Path.GetFullPath
|> delete
Path.Combine("public", "bundle.js.map")
|> Path.GetFullPath
|> delete
Target "Clean" <| fun _ ->
[ testsPath </> "bin"
testsPath </> "obj"
libPath </> "bin"
libPath </> "obj"
samplePath </> "obj"
samplePath </> "bin" ]
|> CleanDirs
cleanBundles()
Target "InstallNpmPackages" (fun _ ->
printfn "Node version:"
run nodeTool "--version" __SOURCE_DIRECTORY__
run "yarn" "--version" __SOURCE_DIRECTORY__
run "yarn" "install" __SOURCE_DIRECTORY__
)
Target "RestoreFableTestProject" <| fun _ ->
run dotnetCli "restore" testsPath
Target "RunLiveTests" <| fun _ ->
run "npm" "start" __SOURCE_DIRECTORY__
let publish projectPath = fun () ->
[ projectPath </> "bin"
projectPath </> "obj" ] |> CleanDirs
run dotnetCli "restore --no-cache" projectPath
run dotnetCli "pack -c Release" projectPath
let nugetKey =
match environVarOrNone "NUGET_KEY" with
| Some nugetKey -> nugetKey
| None -> failwith "The Nuget API key must be set in a NUGET_KEY environmental variable"
let nupkg =
Directory.GetFiles(projectPath </> "bin" </> "Release")
|> Seq.head
|> Path.GetFullPath
let pushCmd = sprintf "nuget push %s -s nuget.org -k %s" nupkg nugetKey
run dotnetCli pushCmd projectPath
Target "PublishNuget" (publish libPath)
Target "CompileFableTestProject" <| fun _ ->
run dotnetCli "tool restore" __SOURCE_DIRECTORY__
run "npm" "run build" "."
Target "RunTests" <| fun _ ->
printfn "Building %s with Fable" testsPath
printfn "Using QUnit cli to run the tests"
run "npm" "run test" "."
cleanBundles()
Target "RunSample" <| fun _ ->
run "npm" "run sample" "."
Target "CompileSample" <| fun _ ->
run "npm" "run build-sample" "."
"Clean"
==> "InstallNpmPackages"
==> "RunSample"
"Clean"
==> "InstallNpmPackages"
==> "CompileSample"
"Clean"
==> "InstallNpmPackages"
==> "RestoreFableTestProject"
==> "RunLiveTests"
"Clean"
==> "InstallNpmPackages"
==> "RestoreFableTestProject"
==> "CompileFableTestProject"
==> "RunTests"
RunTargetOrDefault "RunTests"