-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.fsx
87 lines (67 loc) · 2.42 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
#r "nuget: Fun.Build"
#r "nuget: Fake.IO.FileSystem"
open Fun.Build
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
module Directories =
let sourceDir = __SOURCE_DIRECTORY__
let fableStandaloneNpmSrc =
sourceDir </> "node_modules/@fable-org/fable-standalone/src"
let fableStandaloneNpmDist =
sourceDir </> "node_modules/@fable-org/fable-standalone/dist"
let fableMetadataLib = sourceDir </> "node_modules/@fable-org/fable-metadata/lib/"
let publicReplOutput = sourceDir </> "public/js/repl"
let fableStandaloneFSharp = sourceDir </> "src/Standalone"
let publicMetadataOutput = sourceDir </> "public/metadata"
module Stages =
let clean =
stage "Clean" { run (fun _ -> !! "public/js" ++ "dist/" |> Shell.cleanDirs) }
let dotnetRestore =
stage "Restore .NET dependencies" {
run "dotnet tool restore"
run "dotnet restore"
}
let npmInstall = stage "NPM install" { run "npm install" }
let copyModules =
stage "Copy modules" {
run (fun _ ->
Shell.cleanDir Directories.publicMetadataOutput
Shell.copyDir Directories.publicMetadataOutput Directories.fableMetadataLib (fun _ -> true)
// Change extension to .txt so Github pages compress the files when being served
!!(Directories.publicMetadataOutput </> "*.dll")
|> Seq.iter (fun filename -> Shell.rename (filename + ".txt") filename)
Shell.copyDir Directories.publicReplOutput Directories.fableStandaloneNpmDist (fun _ -> true)
Shell.copyDir Directories.fableStandaloneFSharp Directories.fableStandaloneNpmSrc (fun f ->
f.EndsWith(".fs")))
}
let verify =
stage "Verify" {
stage "Check Formatting" { run "dotnet fantomas --check ." }
stage "Build" { run "dotnet build" }
}
let bundle = stage "Bundle" { run "npm run bundle" }
pipeline "setup" {
Stages.dotnetRestore
Stages.npmInstall
Stages.clean
Stages.copyModules
runIfOnlySpecified
}
pipeline "verify" {
Stages.dotnetRestore
Stages.npmInstall
Stages.clean
Stages.copyModules
Stages.verify
runIfOnlySpecified
}
pipeline "bundle" {
Stages.dotnetRestore
Stages.npmInstall
Stages.clean
Stages.copyModules
Stages.verify
Stages.bundle
runIfOnlySpecified
}