1- #r " paket:
2- nuget Fake.DotNet.Cli
3- nuget Fake.DotNet.Paket
4- nuget Fake.Core.Target
5- nuget Fake.Core.Process
6- nuget Fake.Core.String
7- nuget Fake.Core.ReleaseNotes
8- nuget Fake.IO.FileSystem
9- nuget Fake.Tools.Git
10- nuget Fake.JavaScript.Yarn
11- //"
12- #load " .fake/build.fsx/intellisense.fsx"
13-
14- #nowarn " 52"
1+ #nowarn " 20" " 52"
152
163open Fake.Core
174open Fake.Core .TargetOperators
@@ -20,7 +7,6 @@ open Fake.IO
207open Fake.IO .Globbing .Operators
218open Fake.IO .FileSystemOperators
229open Fake.JavaScript
23-
2410let rootDir = Path.getFullName " ."
2511let srcDir = " ./src"
2612let outputDir = " ./output"
@@ -55,55 +41,56 @@ let dune args = run opamTool "./" (sprintf "exec -- dune %s" args)
5541
5642// Build targets
5743
58- Target.create " Clean" <| fun _ ->
59- !! " src/bin"
60- ++ " src/obj"
61- ++ distDir
62- ++ " src/.fable"
63- |> Seq.iter Shell.cleanDir
44+ let setup () =
45+ Target.create " Clean" <| fun _ ->
46+ !! " src/bin"
47+ ++ " src/obj"
48+ ++ distDir
49+ ++ " src/.fable"
50+ |> Seq.iter Shell.cleanDir
6451
65- !! " src/**/*fs.js"
66- ++ " src/**/*fs.js.map"
67- |> Seq.iter Shell.rm
52+ !! " src/**/*fs.js"
53+ ++ " src/**/*fs.js.map"
54+ |> Seq.iter Shell.rm
6855
69- Target.create " Restore" <| fun _ ->
70- DotNet.restore
71- ( DotNet.Options.withWorkingDirectory __ SOURCE_ DIRECTORY__)
72- " ts2ocaml.sln"
56+ Target.create " Restore" <| fun _ ->
57+ DotNet.restore
58+ ( DotNet.Options.withWorkingDirectory __ SOURCE_ DIRECTORY__)
59+ " ts2ocaml.sln"
7360
74- Target.create " YarnInstall" <| fun _ ->
75- Yarn.installFrozenLockFile ( fun ``params`` ->
76- { `` params `` with WorkingDirectory = " ./" })
61+ Target.create " YarnInstall" <| fun _ ->
62+ Yarn.installFrozenLockFile ( fun ``params`` ->
63+ { `` params `` with WorkingDirectory = " ./" })
7764
78- Target.create " Prepare" ignore
65+ Target.create " Prepare" ignore
7966
80- Target.create " BuildForPublish" <| fun _ ->
81- dotnetExec " fable" $" {srcDir} --sourceMaps --run webpack --mode=production"
67+ Target.create " BuildForPublish" <| fun _ ->
68+ dotnetExec " fable" $" {srcDir} --sourceMaps --run webpack --mode=production"
8269
83- Target.create " BuildForTest" <| fun _ ->
84- dotnetExec " fable" $" {srcDir} --sourceMaps --define DEBUG --run webpack --mode=development"
70+ Target.create " BuildForTest" <| fun _ ->
71+ dotnetExec " fable" $" {srcDir} --sourceMaps --define DEBUG --run webpack --mode=development"
8572
86- Target.create " Build" ignore
73+ Target.create " Build" ignore
8774
88- Target.create " Watch" <| fun _ ->
89- dotnetExec " fable" $" watch {srcDir} --sourceMaps --define DEBUG --run webpack -w --mode=development"
75+ Target.create " Watch" <| fun _ ->
76+ dotnetExec " fable" $" watch {srcDir} --sourceMaps --define DEBUG --run webpack -w --mode=development"
9077
91- Target.create " TestComplete" ignore
78+ Target.create " TestComplete" ignore
9279
93- " Clean"
94- ==> " YarnInstall"
95- ==> " Restore"
96- ==> " Prepare"
97- ==> " Build"
80+ " Clean"
81+ ==> " YarnInstall"
82+ ==> " Restore"
83+ ==> " Prepare"
84+ ==> " Build"
9885
99- " Prepare"
100- ?=> " BuildForTest"
101- ?=> " TestComplete"
102- ?=> " BuildForPublish"
103- ==> " Build"
86+ " Prepare"
87+ ?=> " BuildForTest"
88+ ?=> " TestComplete"
89+ ?=> " BuildForPublish"
90+ ==> " Build"
10491
105- " Prepare"
106- ?=> " Watch"
92+ " Prepare"
93+ ?=> " Watch"
10794
10895// Test targets
10996
@@ -157,24 +144,25 @@ module Test =
157144 printfn " * copied to %s " file
158145 inDirectory testDir <| fun () -> dune " build"
159146
160- Target.create " TestJsooClean" <| fun _ -> Test.Jsoo.clean ()
161- Target.create " TestJsooGenerateBindings" <| fun _ -> Test.Jsoo.generateBindings ()
162- Target.create " TestJsooBuild" <| fun _ -> Test.Jsoo.build ()
163- Target.create " TestJsoo" ignore
147+ let setup () =
148+ Target.create " TestJsooClean" <| fun _ -> Jsoo.clean ()
149+ Target.create " TestJsooGenerateBindings" <| fun _ -> Jsoo.generateBindings ()
150+ Target.create " TestJsooBuild" <| fun _ -> Jsoo.build ()
151+ Target.create " TestJsoo" ignore
164152
165- " BuildForTest"
166- ==> " TestJsooClean"
167- ==> " TestJsooGenerateBindings"
168- ==> " TestJsooBuild"
169- ==> " TestJsoo"
153+ " BuildForTest"
154+ ==> " TestJsooClean"
155+ ==> " TestJsooGenerateBindings"
156+ ==> " TestJsooBuild"
157+ ==> " TestJsoo"
170158
171- Target.create " Test" ignore
172- Target.create " TestOnly" ignore
159+ Target.create " Test" ignore
160+ Target.create " TestOnly" ignore
173161
174- " TestJsoo"
175- ==> " TestOnly"
176- ==> " TestComplete"
177- ==> " Test"
162+ " TestJsoo"
163+ ==> " TestOnly"
164+ ==> " TestComplete"
165+ ==> " Test"
178166
179167// Publish targets
180168
@@ -222,33 +210,49 @@ module Publish =
222210 let testBuild () =
223211 inDirectory targetDir <| fun () -> dune " build"
224212
225- Target.create " Publish" <| fun _ -> ()
226- Target.create " PublishOnly" <| fun _ -> ()
213+ let setup () =
214+ Target.create " Publish" <| fun _ -> ()
215+ Target.create " PublishOnly" <| fun _ -> ()
216+
217+ Target.create " PublishNpm" <| fun _ ->
218+ Npm.updateVersion ()
219+
220+ Target.create " PublishJsoo" <| fun _ ->
221+ Jsoo.copyArtifacts ()
222+ Jsoo.updateVersion ()
223+ Jsoo.testBuild ()
227224
228- Target.create " PublishNpm" <| fun _ ->
229- Publish.Npm.updateVersion ()
225+ " BuildForPublish"
226+ ==> " PublishNpm"
227+ ==> " PublishJsoo"
228+ ==> " PublishOnly"
229+ ==> " Publish"
230230
231- Target.create " PublishJsoo" <| fun _ ->
232- Publish.Jsoo.copyArtifacts ()
233- Publish.Jsoo.updateVersion ()
234- Publish.Jsoo.testBuild ()
231+ " TestJsoo" ==> " PublishJsoo"
235232
236- " BuildForPublish"
237- ==> " PublishNpm"
238- ==> " PublishJsoo"
239- ==> " PublishOnly"
240- ==> " Publish"
233+ " Build" ?=> " Test" ?=> " Publish"
241234
242- " TestJsoo" ==> " PublishJsoo"
235+ [<EntryPoint>]
236+ let main argv =
237+ Shell.cd __ SOURCE_ DIRECTORY__
243238
244- " Build" ?=> " Test" ?=> " Publish"
239+ argv
240+ |> Array.toList
241+ |> Context.FakeExecutionContext.Create false " build.fsx"
242+ |> Context.RuntimeContext.Fake
243+ |> Context.setExecutionContext
245244
246- Target.create " All" ignore
245+ setup ()
246+ Test.setup ()
247+ Publish.setup ()
247248
248- " Build"
249- ==> " Test"
250- ==> " Publish"
251- ==> " All"
249+ Target.create " All" ignore
250+ " Build"
251+ ==> " Test"
252+ ==> " Publish"
253+ ==> " All"
252254
253- // start build
254- Target.runOrDefault " Build"
255+ // start build
256+ Target.runOrDefault " All"
257+
258+ 0
0 commit comments