Skip to content

Commit

Permalink
FAKE updates template.json with Fabulous version
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Sep 13, 2018
1 parent 5d79703 commit 5115891
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 310 deletions.
2 changes: 1 addition & 1 deletion Fabulous.LiveUpdate/LiveUpdate.fs
Expand Up @@ -158,7 +158,7 @@ type HttpServer(?port) =
</body>
</html>"""
|> fun s -> s.Replace("FABULOUS_VERSION", AssemblyVersionInformation.AssemblyVersion)
|> fun s -> s.Replace("PORT", string port)
.Replace("PORT", string port)
}

printfn "LiveUpdate: setting response code to 200, response = %s" resString
Expand Down
23 changes: 22 additions & 1 deletion build.fsx
@@ -1,11 +1,13 @@
// include Fake lib
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
#r "packages/FAKE/tools/Newtonsoft.Json.dll"
open Fake
open System
open System.IO
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Newtonsoft.Json
open Newtonsoft.Json.Linq

let buildDir nuget = if nuget then "./build_output" else "./build_output/tools"
let release = LoadReleaseNotes "RELEASE_NOTES.md"
Expand All @@ -18,6 +20,8 @@ let projects =
("fscd/fscd.fsproj", "fscd", "F# Compiler Daemon", false)
("Fabulous.LiveUpdate/Fabulous.LiveUpdate.fsproj", "Fabulous.LiveUpdate", "F# Functional App Dev Framework Live Update", true) ]

let templateFiles = "templates/**/.template.config/template.json"

Target "Build" (fun _ ->

// needed or else 'project.assets.json' not found'
Expand Down Expand Up @@ -66,6 +70,22 @@ Target "AssemblyInfo" (fun _ ->
CreateFSharpAssemblyInfo (projFolder @@ "AssemblyInfo.fs") projDetails
)

// Update the template.json files with the latest version
Target "TemplatesVersion" (fun _ ->
let files = !! templateFiles

for file in files do
StringHelper.ReadFileAsString file
|> JObject.Parse
|> (fun o ->
let prop = o.["symbols"].["FabulousPkgsVersion"].["defaultValue"] :?> JValue
prop.Value <- release.AssemblyVersion
o
)
|> (fun o -> JsonConvert.SerializeObject(o, Formatting.Indented))
|> StringHelper.WriteStringToFile false file
)

// Build a NuGet package
Target "LibraryNuGet" (fun _ ->
for (projFile, _projName, _summary, nuget) in projects do
Expand Down Expand Up @@ -131,6 +151,7 @@ Target "Test" DoNothing

"Clean"
==> "AssemblyInfo"
==> "TemplatesVersion"
==> "Build"
==> "LibraryNuGet"
==> "TemplatesNuGet"
Expand Down

0 comments on commit 5115891

Please sign in to comment.