Skip to content

Commit

Permalink
Modernize build
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Feb 20, 2019
1 parent 6b94129 commit 620584b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
38 changes: 11 additions & 27 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 _ ->
Expand Down Expand Up @@ -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 _ ->
Expand All @@ -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"
Expand All @@ -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" "" }

Expand Down
26 changes: 26 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -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
}
};
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ group Test
group Build
source https://nuget.org/api/v2

nuget FAKE
nuget FAKE < 5
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 620584b

Please sign in to comment.