forked from fable-compiler/Fable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
594 lines (481 loc) · 22.1 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
#load "src/Fable.PublishUtils/PublishUtils.fs"
open PublishUtils
open System
open System.Text.RegularExpressions
// Appveyor artifact
let FABLE_BRANCH = "master"
// ncave FCS fork
let FCS_REPO = "https://github.com/ncave/fsharp"
let FCS_REPO_LOCAL = "../fsharp_fable"
let FCS_REPO_FABLE_BRANCH = "fable"
let FCS_REPO_SERVICE_SLIM_BRANCH = "service_slim"
let BUILD_ARGS =
fsi.CommandLineArgs
|> Array.skip 1
|> List.ofArray
let BUILD_ARGS_LOWER =
BUILD_ARGS
|> List.map (fun x -> x.ToLower())
module Util =
let cleanDirs dirs =
for dir in dirs do
removeDirRecursive dir
let updateVersionInFableTransforms version =
let filePath = "src/Fable.Transforms/Global/Compiler.fs"
// printfn "VERSION %s" version
Regex.Replace(
readFile filePath,
@"let \[<Literal>] VERSION = "".*?""",
$"let [<Literal>] VERSION = \"{version}\"")
|> writeFile filePath
let updatePkgVersionInFsproj projFile version =
readFile projFile
|> replaceRegex Publish.NUGET_PACKAGE_VERSION (fun m ->
m.Groups.[1].Value + version + m.Groups.[3].Value)
|> writeFile projFile
let runTSLint projectDir =
run ("npm run tslint -- --project " + projectDir)
let runTypeScript projectDir =
run ("npm run tsc -- --project " + projectDir)
let runFableWithArgs projectDir args =
run ("dotnet run -c Release --project src/Fable.Cli -- " + projectDir + " " + String.concat " " args)
let runFableWithArgsAsync projectDir args =
runAsync ("dotnet run -c Release --project src/Fable.Cli -- " + projectDir + " " + String.concat " " args)
let runNpx command args =
run ("npx " + command + " " + (String.concat " " args))
let runNpmScript script args =
run ("npm run " + script + " -- " + (String.concat " " args))
let runNpmScriptAsync script args =
runAsync ("npm run " + script + " -- " + (String.concat " " args))
let runFable projectDir =
runFableWithArgs projectDir []
let runMocha testDir =
runNpmScript "mocha" [$"{testDir} --reporter dot -t 10000"]
let resolveDir dir =
__SOURCE_DIRECTORY__ </> dir
open Util
module Unused =
let downloadAndExtractTo (url: string) (targetDir: string) =
sprintf "npx download --extract --out %s \"%s\"" targetDir url |> run
let coverage() =
// report converter
// https://github.com/danielpalme/ReportGenerator
// dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
if not (pathExists "./bin/tools/reportgenerator") && not (pathExists "./bin/tools/reportgenerator.exe") then
runInDir "." "dotnet tool install dotnet-reportgenerator-globaltool --tool-path bin/tools"
let reportGen =
if pathExists "./bin/tools/reportgenerator" then "bin/tools/reportgenerator"
else "bin\\tools\\reportgenerator.exe"
// if not (pathExists "build/fable-library") then
// buildLibrary()
cleanDirs ["build/tests"]
runFable "tests"
// JS
run "npx nyc mocha build/tests --require source-map-support/register --reporter dot -t 10000"
runInDir "." (reportGen + " \"-reports:build/coverage/nyc/lcov.info\" -reporttypes:Html \"-targetdir:build/coverage/nyc/html\" ")
// .NET
//runInDir "tests/Main" "dotnet build /t:Collect_Coverage"
cleanDirs ["build/coverage/netcoreapp2.0/out"]
runInDir "." (reportGen + " \"-reports:build/coverage/netcoreapp2.0/coverage.xml\" -reporttypes:Html \"-targetdir:build/coverage/netcoreapp2.0/html\" ")
// TARGETS ---------------------------
let buildLibraryWithOptions (opts: {| watch: bool |}) =
let baseDir = __SOURCE_DIRECTORY__
let projectDir = baseDir </> "src/fable-library"
let buildDir = baseDir </> "build/fable-library"
let fableOpts = [
"--outDir " + buildDir
"--fableLib " + buildDir
"--exclude Fable.Core"
"--define FX_NO_BIGINT"
"--define FABLE_LIBRARY"
if opts.watch then "--watch"
]
cleanDirs [buildDir]
runInDir baseDir "npm install"
makeDirRecursive buildDir
copyFile (projectDir </> "package.json") buildDir
if opts.watch then
Async.Parallel [
runNpmScriptAsync "tsc" [
"--project " + projectDir
"--watch"
]
runFableWithArgsAsync projectDir fableOpts
] |> runAsyncWorkflow
else
runTSLint projectDir
runTypeScript projectDir
runFableWithArgs projectDir fableOpts
removeDirRecursive (buildDir </> ".fable")
let buildLibrary() = buildLibraryWithOptions {| watch = false |}
let watchLibrary() = buildLibraryWithOptions {| watch = true |}
let buildLibraryIfNotExists() =
let baseDir = __SOURCE_DIRECTORY__
if not (pathExists (baseDir </> "build/fable-library")) then
buildLibrary()
let buildLibraryTs() =
let projectDir = "src/fable-library"
let buildDirTs = "build/fable-library-ts"
let buildDirJs = "build/fable-library-js"
cleanDirs [buildDirTs; buildDirJs]
runFableWithArgs projectDir [
"--outDir " + buildDirTs
"--fableLib " + buildDirTs
"--lang TypeScript"
"--exclude Fable.Core"
"--define FX_NO_BIGINT"
"--define FABLE_LIBRARY"
]
// TODO: cleanDirs [buildDirTs </> "fable-library"]
// TODO: copy *.ts/*.js from projectDir to buildDir
runInDir buildDirTs "npm run tsc -- --init --target es2020 --module es2020 --allowJs"
runInDir buildDirTs ("npm run tsc -- --outDir ../../" + buildDirJs)
// Like testJs() but doesn't create bundles/packages for fable-standalone & friends
// Mainly intended for CI
let testJsFast() =
runFableWithArgs "src/fable-standalone/src" [
"--noCache"
]
runFableWithArgs "src/fable-compiler-js/src" [
"--exclude Fable.Core"
"--define LOCAL_TEST"
]
let fableJs = "./src/fable-compiler-js/src/app.fs.js"
let testProj = "tests/Main/Fable.Tests.fsproj"
let buildDir = "build/tests-js"
run $"node {fableJs} {testProj} {buildDir}"
runMocha buildDir
let buildStandalone (opts: {| minify: bool; watch: bool |}) =
buildLibraryIfNotExists()
printfn "Building standalone%s..." (if opts.minify then "" else " (no minification)")
let projectDir = "src/fable-standalone/src"
let libraryDir = "build/fable-library"
let buildDir = "build/fable-standalone"
let distDir = "src/fable-standalone/dist"
let rollupTarget =
match opts.watch, opts.minify with
| true, _ ->
match BUILD_ARGS with
| _::rollupTarget::_ -> rollupTarget
| _ -> failwith "Pass the bundle output, e.g.: npm run build watch-standalone ../repl3/public/js/repl/bundle.min.js"
| false, true -> buildDir </> "bundle.js"
| false, false -> distDir </> "bundle.min.js"
let rollupArgs = [
buildDir </> "bundle/Main.js"
"-o " + rollupTarget
"--format umd"
"--name __FABLE_STANDALONE__"
]
// cleanup
if not opts.watch then
cleanDirs [buildDir; distDir]
makeDirRecursive distDir
// build standalone bundle
runFableWithArgs projectDir [
"--outDir " + buildDir </> "bundle"
if opts.watch then
"--watch"
"--run rollup"
yield! rollupArgs
"--watch"
]
// build standalone worker
runFableWithArgs (projectDir + "/Worker") [
"--outDir " + buildDir + "/worker"
]
// make standalone bundle dist
runNpmScript "rollup" rollupArgs
if opts.minify then
runNpmScript "terser" [
buildDir </> "bundle.js"
"-o " + distDir </> "bundle.min.js"
"--mangle"
"--compress"
]
// make standalone worker dist
runNpmScript "rollup" [$"{buildDir}/worker/Worker.js -o {buildDir}/worker.js --format iife"]
// runNpx "webpack" [sprintf "--entry ./%s/worker.js --output ./%s/worker.min.js --config ./%s/../worker.config.js" buildDir distDir projectDir]
runNpmScript "terser" [$"{buildDir}/worker.js -o {distDir}/worker.min.js --mangle --compress"]
// print bundle size
fileSizeInBytes (distDir </> "bundle.min.js") / 1000. |> printfn "Bundle size: %fKB"
fileSizeInBytes (distDir </> "worker.min.js") / 1000. |> printfn "Worker size: %fKB"
// Put fable-library files next to bundle
let libraryTarget = distDir </> "fable-library"
copyDirRecursive libraryDir libraryTarget
// These files will be used in the browser, so make sure the import paths include .js extension
// let reg = Regex(@"^import (.*"".*)("".*)$", RegexOptions.Multiline)
// getFullPathsInDirectoryRecursively libraryTarget
// |> Array.filter (fun file -> file.EndsWith(".js"))
// |> Array.iter (fun file ->
// reg.Replace(readFile file, fun m ->
// let fst = m.Groups.[1].Value
// if fst.EndsWith(".js") then m.Value
// else sprintf "import %s.js%s" fst m.Groups.[2].Value)
// |> writeFile file)
// Bump version
// let compilerVersion = Publish.loadReleaseVersion "src/fable-compiler"
// let standaloneVersion = Publish.loadNpmVersion projectDir
// let (comMajor, comMinor, _, comPrerelease) = Publish.splitVersion compilerVersion
// let (staMajor, staMinor, staPatch, _) = Publish.splitVersion standaloneVersion
// Publish.bumpNpmVersion projectDir
// (if comMajor > staMajor || comMinor > staMinor then compilerVersion
// else sprintf "%i.%i.%i%s" staMajor staMinor (staPatch + 1) comPrerelease)
let buildCompilerJs(minify: bool) =
let projectDir = "src/fable-compiler-js/src"
let buildDir = "build/fable-compiler-js"
let distDir = "src/fable-compiler-js/dist"
if not (pathExists "build/fable-standalone") then
buildStandalone {|minify=minify; watch=false|}
cleanDirs [buildDir; distDir]
makeDirRecursive distDir
runFableWithArgs projectDir [
"--outDir " + buildDir
"--exclude Fable.Core"
]
let rollupTarget = if minify then distDir </> "app.js" else distDir </> "app.min.js"
run $"npx rollup {buildDir}/app.js -o {rollupTarget} --format umd --name Fable"
if minify then
run $"npx terser {distDir}/app.js -o {distDir}/app.min.js --mangle --compress"
// Copy fable-library
copyDirRecursive ("build/fable-library") (distDir </> "fable-library")
// Copy fable-metadata
copyDirRecursive ("src/fable-metadata/lib") (distDir </> "fable-metadata")
let testJs(minify) =
let fableDir = "src/fable-compiler-js"
let buildDir = "build/tests-js"
if not (pathExists "build/fable-compiler-js") then
buildCompilerJs(minify)
cleanDirs [buildDir]
// Link fable-compiler-js to local packages
runInDir fableDir "npm link ../fable-metadata"
runInDir fableDir "npm link ../fable-standalone"
// Test fable-compiler-js locally
run $"node {fableDir} tests/Main/Fable.Tests.fsproj {buildDir}"
runMocha buildDir
// // Another local fable-compiler-js test
// runInDir (fableDir </> "test") "node .. test_script.fsx"
// runInDir (fableDir </> "test") "node test_script.fsx.js"
// Unlink local packages after test
runInDir fableDir "npm unlink ../fable-metadata && cd ../fable-metadata && npm unlink"
runInDir fableDir "npm unlink ../fable-standalone && cd ../fable-standalone && npm unlink"
let testReact() =
runFableWithArgs "tests/React" ["--noCache"]
runInDir "tests/React" "npm i && npm test"
let testCompiler() =
runInDir "tests/Compiler" "dotnet run -c Release"
let testIntegration() =
runInDir "tests/Integration" "dotnet run -c Release"
let compileAndRunTestsWithMocha clean projectDir buildDir =
let projectDir = "tests/" + projectDir
let buildDir = "build/" + buildDir
if clean then
cleanDirs [buildDir]
runFableWithArgs projectDir [
"--outDir " + buildDir
"--exclude Fable.Core"
]
runMocha buildDir
let testMocha clean =
compileAndRunTestsWithMocha clean "Main" "tests"
let testProjectConfigs() =
[ "tests/ProjectConfigs/DebugWithExtraDefines", "Debug"
"tests/ProjectConfigs/CustomConfiguration", "Test"
"tests/ProjectConfigs/ReleaseNoExtraDefines", String.Empty
"tests/ProjectConfigs/ConsoleApp", String.Empty
]
|> List.iter (fun (projectDir, configuration) ->
let buildDir = "build/"+ projectDir
cleanDirs [ buildDir ]
runFableWithArgs projectDir [
"--outDir " + buildDir
"--exclude Fable.Core"
if not(String.IsNullOrEmpty configuration) then
"--configuration " + configuration
]
runMocha buildDir
)
let test() =
buildLibraryIfNotExists()
testMocha true
runInDir "tests/Main" "dotnet run"
// Adaptive tests must go in a different project to avoid conflicts with Queue shim, see #2559
compileAndRunTestsWithMocha true "Adaptive" "tests-adaptive"
testReact()
testProjectConfigs()
testCompiler()
testIntegration()
if envVarOrNone "CI" |> Option.isSome then
testJsFast()
let buildLocalPackageWith pkgDir pkgCommand fsproj action =
let version = "3.0.0-local-build-" + DateTime.Now.ToString("yyyyMMdd-HHmm")
action version
updatePkgVersionInFsproj fsproj version
run $"dotnet pack {fsproj} -p:Pack=true -c Release -o {pkgDir}"
// Return install command
$"""dotnet {pkgCommand} --version "{version}" --add-source {fullPath pkgDir}"""
let buildLocalPackage pkgDir =
buildLocalPackageWith pkgDir
"tool install fable"
(resolveDir "src/Fable.Cli/Fable.Cli.fsproj") (fun version ->
buildLibrary()
updateVersionInFableTransforms version)
let testRepos() =
let repos = [
"https://github.com/alfonsogarciacaro/FsToolkit.ErrorHandling:update-fable-3", "npm i && npm test"
"https://github.com/fable-compiler/fable-promise:master", "npm i && npm test"
"https://github.com/alfonsogarciacaro/Thoth.Json:nagareyama", "dotnet paket restore && npm i && dotnet fable tests -o tests/bin --run mocha tests/bin"
"https://github.com/alfonsogarciacaro/FSharp.Control.AsyncSeq:nagareyama", "cd tests/fable && npm i && npm test"
"https://github.com/alfonsogarciacaro/Fable.Extras:nagareyama", "dotnet paket restore && npm i && npm test"
"https://github.com/alfonsogarciacaro/Fable.Jester:nagareyama", "npm i && npm test"
"https://github.com/Zaid-Ajaj/Fable.SimpleJson:master", "npm i && npm run test-nagareyama"
]
let testDir = tempPath() </> "fable-repos"
printfn $"Cloning repos to: {testDir}"
cleanDirs [testDir]
makeDirRecursive testDir
let pkgInstallCmd = buildLocalPackage (testDir </> "pkg")
for (repo, command) in repos do
let url, branch = let i = repo.LastIndexOf(":") in repo.[..i-1], repo.[i+1..]
let name = url.[url.LastIndexOf("/") + 1..]
runInDir testDir $"git clone {url} {name}"
let repoDir = testDir </> name
runInDir repoDir ("git checkout " + branch)
runInDir repoDir "dotnet tool uninstall fable"
runInDir repoDir pkgInstallCmd
runInDir repoDir "dotnet tool restore"
runInDir repoDir command
let githubRelease() =
match envVarOrNone "GITHUB_USER", envVarOrNone "GITHUB_TOKEN" with
| Some user, Some token ->
try
let version, notes = Publish.loadReleaseVersionAndNotes "src/Fable.Cli"
let notes = notes |> Array.map (fun n -> $"""'{n.Replace("'", @"\'").Replace("`", @"\`")}'""") |> String.concat ","
run $"git commit -am \"Release {version}\" && git push"
runSilent $"""node --eval "require('ghreleases').create({{ user: '{user}', token: '{token}', }}, 'fable-compiler', 'Fable', {{ tag_name: '{version}', name: '{version}', body: [{notes}].join('\n'), }}, (err, res) => {{ if (err != null) {{ console.error(err) }} }})" """
printfn "Github release %s created successfully" version
with ex ->
printfn "Github release failed: %s" ex.Message
| _ -> failwith "Expecting GITHUB_USER and GITHUB_TOKEN enviromental variables"
let copyFcsRepo sourceDir =
let targetDir = "src/fcs-fable"
let path1 = "fcs/fcs-fable"
let path2 = "src/Compiler"
cleanDirs [targetDir]
copyDirRecursive (sourceDir </> path1) targetDir
copyDirRecursive (sourceDir </> path2) (targetDir </> path2)
removeFile (targetDir </> ".gitignore")
let projPath = (targetDir </> "fcs-fable.fsproj")
let projText = readFile projPath
let projText =
Regex.Replace(projText,
@"(<FSharpSourcesRoot>\$\(MSBuildProjectDirectory\)).*?(<\/FSharpSourcesRoot>)",
"$1/src/Compiler$2")
// let projText =
// Regex.Replace(projText,
// @"artifacts\/bin\/FSharp.Core\/Release\/netstandard2.0",
// "lib/fcs")
projText |> writeFile projPath
let syncFcsRepo() =
// FAKE is giving lots of problems with the dotnet SDK version, ignore it
let cheatWithDotnetSdkVersion dir f =
let path = dir </> "build.fsx"
let script = readFile path
Regex.Replace(script, @"let dotnetExePath =[\s\S]*DotNetCli\.InstallDotNetSDK", "let dotnetExePath = \"dotnet\" //DotNetCli.InstallDotNetSDK") |> writeFile path
f ()
runInDir dir "git reset --hard"
printfn "Expecting %s repo to be cloned at %s" FCS_REPO FCS_REPO_LOCAL
// TODO: Prompt to reset --hard changes
// service_slim
runInDir FCS_REPO_LOCAL ("git checkout " + FCS_REPO_SERVICE_SLIM_BRANCH)
runInDir FCS_REPO_LOCAL "git pull"
cheatWithDotnetSdkVersion (FCS_REPO_LOCAL </> "fcs") (fun () ->
runBashOrCmd (FCS_REPO_LOCAL </> "fcs") "build" "")
copyFile (FCS_REPO_LOCAL </> "artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Compiler.Service.dll") "../fable/lib/fcs/"
copyFile (FCS_REPO_LOCAL </> "artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Compiler.Service.xml") "../fable/lib/fcs/"
copyFile (FCS_REPO_LOCAL </> "artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Core.dll") "../fable/lib/fcs/"
copyFile (FCS_REPO_LOCAL </> "artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Core.xml") "../fable/lib/fcs/"
// fcs-fable
runInDir FCS_REPO_LOCAL ("git checkout " + FCS_REPO_FABLE_BRANCH)
runInDir FCS_REPO_LOCAL "git pull"
cheatWithDotnetSdkVersion (FCS_REPO_LOCAL </> "fcs") (fun () ->
runBashOrCmd (FCS_REPO_LOCAL </> "fcs") "build" "CodeGen.Fable")
copyFcsRepo FCS_REPO_LOCAL
let packages =
["Fable.AST", doNothing
"Fable.Core", doNothing
"Fable.Cli", (fun () ->
Publish.loadReleaseVersion "src/Fable.Cli" |> updateVersionInFableTransforms
buildLibrary())
"Fable.PublishUtils", doNothing
"fable-metadata", doNothing
"fable-standalone", fun () -> buildStandalone {|minify=true; watch=false|}
"fable-compiler-js", fun () -> buildCompilerJs true
]
let publishPackages restArgs =
let packages =
match List.tryHead restArgs with
| Some pkg -> packages |> List.filter (fun (name,_) -> name = pkg)
| None -> packages
for (pkg, buildAction) in packages do
if System.Char.IsUpper pkg.[0] then
let projFile = "src" </> pkg </> pkg + ".fsproj"
pushFableNuget projFile ["Pack", "true"] buildAction
else
pushNpm ("src" </> pkg) buildAction
let minify<'T> =
BUILD_ARGS_LOWER |> List.contains "--no-minify" |> not
match BUILD_ARGS_LOWER with
// | "check-sourcemaps"::_ ->
// ("src/quicktest/Quicktest.fs", "src/quicktest/bin/Quicktest.js", "src/quicktest/bin/Quicktest.js.map")
// |||> sprintf "nodemon --watch src/quicktest/bin/Quicktest.js --exec 'source-map-visualization --sm=\"%s;%s;%s\"'"
// |> List.singleton |> quicktest
// | "coverage"::_ -> coverage()
| "test"::_ -> test()
| "test-mocha"::_ -> testMocha true
| "test-mocha-fast"::_ -> testMocha false
| "test-configs"::_ -> testProjectConfigs()
| "test-js"::_ -> testJs(minify)
| "test-js-fast"::_ -> testJsFast()
| "test-react"::_ -> testReact()
| "test-compiler"::_ -> testCompiler()
| "test-integration"::_ -> testIntegration()
| "quicktest"::_ ->
buildLibraryIfNotExists()
removeDirRecursive "src/quicktest/fable_modules"
run "dotnet watch --project src/Fable.Cli run -- watch --cwd ../quicktest --exclude Fable.Core --noCache --runScript"
| "run"::_ ->
buildLibraryIfNotExists()
// Don't take it from pattern matching as that one uses lowered args
let restArgs = BUILD_ARGS |> List.skip 1 |> String.concat " "
run $"""dotnet run -c Release --project {resolveDir "src/Fable.Cli"} -- {restArgs}"""
| "package"::_ ->
let pkgInstallCmd = buildLocalPackage (resolveDir "temp/pkg")
printfn $"\nPackage has been created, use the following command to install it:\n {pkgInstallCmd}\n"
| "package-core"::_ ->
let pkgInstallCmd = buildLocalPackageWith (resolveDir "temp/pkg") "add package Fable.Core" (resolveDir "src/Fable.Core/Fable.Core.fsproj") ignore
printfn $"\nFable.Core package has been created, use the following command to install it:\n {pkgInstallCmd}\n"
| ("watch-library")::_ -> watchLibrary()
| ("fable-library"|"library")::_ -> buildLibrary()
| ("fable-library-ts"|"library-ts")::_ -> buildLibraryTs()
| ("fable-compiler-js"|"compiler-js")::_ -> buildCompilerJs(minify)
| ("fable-standalone"|"standalone")::_ -> buildStandalone {|minify=minify; watch=false|}
| "watch-standalone"::_ -> buildStandalone {|minify=false; watch=true|}
| "publish"::restArgs -> publishPackages restArgs
| "github-release"::_ ->
publishPackages []
githubRelease ()
| "sync-fcs-repo"::_ -> syncFcsRepo()
| "copy-fcs-repo"::_ -> copyFcsRepo FCS_REPO_LOCAL
| "test-repos"::_ -> testRepos()
| _ ->
printfn """Please pass a target name. Examples:
- Use `test` to run tests:
dotnet fsi build.fsx test
- Use `package` to build a local package:
dotnet fsi build.fsx package
- Use `run` to compile a project with development version:
dotnet fsi build.fsx run ../path/to/my/project [Fable options]
- Use `quicktest` to quickly test development version with src/quicktest project:
dotnet fsi build.fsx quicktest
"""
printfn "Build finished successfully"