-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.fsx
174 lines (136 loc) · 4.15 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
168
169
170
171
172
173
174
#r "paket: groupref FakeBuild //"
#load ".fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#r "Facades/netstandard" // https://github.com/ionide/ionide-vscode-fsharp/issues/839#issuecomment-396296095
#endif
open System
open System.Text.Json
open Fake.Core
open Fake.Core.TargetOperators
open Fake.Core.Xml
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.JavaScript
let getExitCode (res: ProcessResult) =
res.ExitCode
let failIfNonZero (exitCode: int) =
if exitCode <> 0 then failwithf "Failed with exit code %i" exitCode
Target.create "Clean" (fun _ ->
!! "**/bin"
++ "**/obj"
++ "**/dist"
++ "**/deploy"
++ "**/*.fable"
-- "**/node_modules/**"
|> Shell.cleanDirs
)
Target.create "DotNetRestore" (fun _ ->
DotNet. restore id "Feliz.MaterialUI.sln"
)
Target.create "Build" (fun _ ->
DotNet.build
(fun c -> { c with Configuration = DotNet.BuildConfiguration.Release })
"Feliz.MaterialUI.sln"
)
Target.create "RegenerateFromLive" (fun _ ->
DotNet.exec
// Set working directory to output directory to get same paths as when running in VS
(fun c -> { c with WorkingDirectory = "src/Feliz.Generator.MaterialUI/bin/Release/netcoreapp3.1" })
"run"
"--project ../../.. -- --refresh"
|> getExitCode |> failIfNonZero
)
Target.create "RegenerateFromCache" (fun _ ->
DotNet.exec
// Set working directory to output directory to get same paths as when running in VS
(fun c -> { c with WorkingDirectory = "src/Feliz.Generator.MaterialUI/bin/Release/netcoreapp3.1" })
"run"
"--project ../../.."
|> getExitCode |> failIfNonZero
)
Target.create "Pack" (fun _ ->
DotNet.exec id "paket" "pack dist" |> getExitCode |> failIfNonZero
)
Target.create "Docs:NpmInstall" (fun _ ->
Npm.install (fun c -> { c with WorkingDirectory = "docs-app" } )
)
Target.create "Docs:Run" (fun _ ->
Npm.exec "start" (fun c -> { c with WorkingDirectory = "docs-app" } )
)
Target.create "Docs:Build" (fun _ ->
Npm.run "build" (fun c -> { c with WorkingDirectory = "docs-app" } )
)
Target.create "Docs:Publish" (fun _ ->
Shell.Exec("node", "publish.js", "docs-app") |> failIfNonZero
)
Target.create "UpdatePackages" (fun _ ->
DotNet.exec id "paket" "update" |> getExitCode |> failIfNonZero
Npm.exec "up" (fun c -> { c with WorkingDirectory = "docs-app" } )
DotNet.exec id "femto" "--resolve docs-app/src" |> getExitCode |> failIfNonZero
)
Target.create "UpdateFemtoVersionMetadata" (fun _ ->
let npm = ProcessUtils.findFilesOnPath "npm" |> Seq.head
let latestCoreStableVersion =
CreateProcess.fromRawCommand npm ["show"; "@material-ui/core"; "versions"; "--json"]
|> CreateProcess.withWorkingDirectory "docs-app"
|> CreateProcess.redirectOutput
|> Proc.run
|> fun r -> r.Result.Output
|> fun s -> printfn "%s" s; s
|> JsonSerializer.Deserialize<seq<string>>
|> Seq.map SemVer.parse
|> Seq.filter (fun v -> v.PreRelease.IsNone)
|> Seq.last
let latestLabVersion =
CreateProcess.fromRawCommand npm ["show"; "@material-ui/lab"; "version"]
|> CreateProcess.withWorkingDirectory "docs-app"
|> CreateProcess.redirectOutput
|> Proc.run
|> fun r -> r.Result.Output
|> SemVer.parse
let v = latestCoreStableVersion
poke
"src/Feliz.MaterialUI/Feliz.MaterialUI.fsproj"
"//NpmPackage[@Name='@material-ui/core']/@Version"
(sprintf "gte %i.%i lt %i" v.Major v.Minor (v.Major + 1u))
poke
"src/Feliz.MaterialUI/Feliz.MaterialUI.fsproj"
"//NpmPackage[@Name='@material-ui/lab']/@Version"
latestLabVersion.AsString
)
Target.create "RegularMaintenance" ignore
Target.create "CiBuild" ignore
"Clean"
==> "DotNetRestore"
==> "Build"
==> "Pack"
"Build"
==> "RegenerateFromLive"
"Build"
==> "RegenerateFromCache"
"Build"
==> "Pack"
"UpdateFemtoVersionMetadata"
==> "UpdatePackages"
==> "RegenerateFromLive"
==> "RegularMaintenance"
"DotNetRestore"
==> "Docs:Run"
"Docs:NpmInstall"
==> "Docs:Run"
"DotNetRestore"
==> "Docs:Build"
"Docs:NpmInstall"
==> "Docs:Build"
"Build"
==> "Docs:Build"
"Docs:Build"
==> "Docs:Publish"
"Pack"
==> "CiBuild"
"Docs:Build"
==> "CiBuild"
Target.runOrDefault "CiBuild"