-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.fsx
More file actions
125 lines (106 loc) · 3 KB
/
build.fsx
File metadata and controls
125 lines (106 loc) · 3 KB
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
#r "paket: groupref FakeBuild //"
#load ".fake/build.fsx/intellisense.fsx"
open System
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.JavaScript
Target.create "Clean" (fun _ ->
!! "src/**/bin"
++ "src/**/obj"
++ "output"
|> Shell.cleanDirs
)
Target.create "DotnetRestore" (fun _ ->
DotNet.restore
(DotNet.Options.withWorkingDirectory __SOURCE_DIRECTORY__)
"Fable.MaterialUI.MaterialDesignIcons.sln"
)
Target.create "NpmInstall" (fun _ ->
Npm.install id
)
Target.create "Generate" (fun _ ->
let firstLower (str: string) =
string (Char.ToLower str.[0]) + str.Substring 1
let names =
!! "node_modules/mdi-material-ui/*.d.ts"
|> Seq.filter (fun path -> not <| path.EndsWith("index.d.ts"))
|> Seq.map (fun path ->
let fullName = FileInfo.ofPath(path).Name
fullName.Substring(0, fullName.Length - 5)
)
let bindingStart = """
//--------------------------------------------//
// This file is auto-generated, see build.fsx //
//--------------------------------------------//
module Fable.MaterialUI.MaterialDesignIcons
open Fable.Core
open Fable.Core.JsInterop
open Fable.React
"""
let bindingLines =
names |> Seq.collect (fun name ->
[
yield sprintf "let inline %sIcon b : ReactElement = " (firstLower name)
yield sprintf " ofImport \"default\" \"mdi-material-ui/%s\" (keyValueList CaseRules.LowerFirst b) []" name
yield ""
]
)
File.replaceContent "src/Fable.MaterialUI.MaterialDesignIcons/Icons.fs" bindingStart
File.write true "src/Fable.MaterialUI.MaterialDesignIcons/Icons.fs" bindingLines
let testStart = """
//--------------------------------------------//
// This file is auto-generated, see build.fsx //
//--------------------------------------------//
module ViewTree
open Fable.React
open Fable.React.Props
open Fable.MaterialUI.MaterialDesignIcons
let root =
fragment [] ([|
"""
let testLines =
names |> Seq.map (fun name ->
sprintf " %sIcon [ Id \"%s\" ]" (firstLower name) name
)
File.replaceContent "src/Test/ViewTree.fs" testStart
File.write true "src/Test/ViewTree.fs" testLines
File.write true "src/Test/ViewTree.fs" [" |] |> Array.toList)"]
)
Target.create "Build" (fun _ ->
!! "src/Fable.MaterialUI.MaterialDesignIcons/Fable.MaterialUI.MaterialDesignIcons.fsproj"
|> Seq.iter (DotNet.build (fun x ->
{ x with
Configuration = DotNet.BuildConfiguration.Release
}
))
)
Target.create "Pack" (fun _ ->
"src/Fable.MaterialUI.MaterialDesignIcons/"
|> DotNet.pack (fun x ->
{ x with
Configuration = DotNet.BuildConfiguration.Release
}
)
)
Target.create "BuildTest" (fun _ ->
Npm.run "build" id
)
Target.create "DevTest" (fun _ ->
Npm.run "start" id
)
// Build order
"Clean"
==> "DotnetRestore"
==> "NpmInstall"
==> "Generate"
==> "Build"
==> "BuildTest"
==> "Pack"
"Build"
==> "DevTest"
// start build
Target.runOrDefault "Pack"