From 620584bd1a38e8750e505a9eecd9cfeedc9f73ba Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 20 Feb 2019 15:29:06 +0100 Subject: [PATCH] Modernize build --- build.fsx | 38 +++++++++++--------------------------- global.json | 26 ++++++++++++++++++++++++++ paket.dependencies | 2 +- paket.lock | 2 +- 4 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 global.json diff --git a/build.fsx b/build.fsx index 25278bf..bab9be9 100644 --- a/build.fsx +++ b/build.fsx @@ -64,7 +64,7 @@ let srcDir = __SOURCE_DIRECTORY__ "src" let testDir = __SOURCE_DIRECTORY__ "tests" "IntegrationTests" -let dotnetcliVersion = "2.0.0" +let dotnetcliVersion = DotNetCli.GetDotNetSDKVersionFromGlobalJson() let mutable dotnetExePath = "dotnet" @@ -144,6 +144,12 @@ FinalTarget "CloseAndroid" (fun _ -> Target "InstallDotNetCore" (fun _ -> dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion + let fi = FileInfo dotnetExePath + let SEPARATOR = if isWindows then ";" else ":" + Environment.SetEnvironmentVariable( + "PATH", + fi.Directory.FullName + SEPARATOR + System.Environment.GetEnvironmentVariable "PATH", + EnvironmentVariableTarget.Process) ) Target "Restore" (fun _ -> @@ -244,13 +250,7 @@ Target "PrepareRelease" (fun _ -> Target "CompileForTest" (fun _ -> ActivateFinalTarget "KillProcess" - let result = - ExecProcess (fun info -> - info.FileName <- dotnetExePath - info.WorkingDirectory <- srcDir - info.Arguments <- " fable npm-run compile-for-test") TimeSpan.MaxValue - - if result <> 0 then failwith "fable shut down. Please check logs above" + run yarnTool "run fable-splitter -c splitter.config.js --define TEST" srcDir ) Target "AssembleForTest" (fun _ -> @@ -260,12 +260,7 @@ Target "AssembleForTest" (fun _ -> Target "BuildRelease" (fun _ -> ActivateFinalTarget "KillProcess" - let result = - ExecProcess (fun info -> - info.FileName <- dotnetExePath - info.WorkingDirectory <- srcDir - info.Arguments <- " fable npm-run build") TimeSpan.MaxValue - if result <> 0 then failwith "fable shut down. Please check logs above" + run yarnTool "run fable-splitter -c splitter.config.js --define RELEASE" srcDir run gradleTool "assembleRelease --console plain" "android" let outFile = "android" "app" "build" "outputs" "apk" "app-release.apk" @@ -275,20 +270,9 @@ Target "BuildRelease" (fun _ -> ) Target "Debug" (fun _ -> - let result = - ExecProcess (fun info -> - info.FileName <- dotnetExePath - info.WorkingDirectory <- srcDir - info.Arguments <- " fable npm-run cold-start") TimeSpan.MaxValue - if result <> 0 then failwith "fable shut down." + run yarnTool "run fable-splitter -c splitter.config.js --define DEBUG" srcDir - let dotnetwatch = async { - let result = - ExecProcess (fun info -> - info.FileName <- dotnetExePath - info.WorkingDirectory <- srcDir - info.Arguments <- " fable npm-run start") TimeSpan.MaxValue - if result <> 0 then failwith "fable shut down." } + let dotnetwatch = async { run yarnTool "run fable-splitter -c splitter.config.js -w --define DEBUG" srcDir } let reactNativeTool = async { run reactNativeTool "run-android" "" } diff --git a/global.json b/global.json new file mode 100644 index 0000000..f6af403 --- /dev/null +++ b/global.json @@ -0,0 +1,26 @@ +var path = require('path') + +function resolve(filePath) { + return path.resolve(__dirname, filePath) +} + +var define = []; +var idx = process.argv.indexOf("--define"); + +if (idx > -1) { + define = [process.argv[idx + 1]]; +} + +console.log("Bundling for " + define + "..."); + +module.exports = { + entry: resolve('src/Nightwatch.fsproj'), + outDir: resolve("out"), + babel: { + // presets: [["es2015", { modules: false }]], + // sourceMaps: true, + }, + fable: { + define: define + } +}; \ No newline at end of file diff --git a/paket.dependencies b/paket.dependencies index eec5084..7752c85 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -23,4 +23,4 @@ group Test group Build source https://nuget.org/api/v2 - nuget FAKE \ No newline at end of file + nuget FAKE < 5 \ No newline at end of file diff --git a/paket.lock b/paket.lock index e0f15ce..42a0aa0 100644 --- a/paket.lock +++ b/paket.lock @@ -480,7 +480,7 @@ NUGET GROUP Build NUGET remote: https://www.nuget.org/api/v2 - FAKE (4.64.4) + FAKE (4.64.16) GROUP Test GENERATE-LOAD-SCRIPTS: ON