From 5167f7f0cf64a8e01b1197a353c863fdf73aa9d1 Mon Sep 17 00:00:00 2001 From: callum vass Date: Tue, 15 May 2018 13:59:35 +0100 Subject: [PATCH 1/2] lowercased parameters and updated sources --- Content/.template.config/template.json | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Content/.template.config/template.json b/Content/.template.config/template.json index 7eba8f04..b33e182d 100644 --- a/Content/.template.config/template.json +++ b/Content/.template.config/template.json @@ -10,7 +10,7 @@ "identity": "SAFE.Template", "shortName": "SAFE", "symbols": { - "Server": { + "server": { "type": "parameter", "dataType": "choice", "defaultValue": "saturn", @@ -29,7 +29,7 @@ } ] }, - "Fulma": { + "fulma": { "type": "parameter", "dataType": "choice", "defaultValue": "basic", @@ -64,19 +64,19 @@ } ] }, - "Remoting": { + "remoting": { "type": "parameter", "dataType": "bool", "defaultValue": "false", "description": "adds Fable.Remoting to server and client" }, - "NPM": { + "npm": { "type": "parameter", "dataType": "bool", "defaultValue": "false", "description": "use NPM instead of default Yarn for JS package management" }, - "Deploy": { + "deploy": { "type": "parameter", "dataType": "choice", "defaultValue": "none", @@ -102,66 +102,66 @@ "modifiers": [ { "exclude": "**/ServerSuave.fs", - "condition": "(Server != \"suave\")" + "condition": "(server != \"suave\")" }, { "rename": { "ServerSuave.fs": "Server.fs" } }, { "exclude": "**/Suaveweb.config", - "condition": "(Server != \"suave\") || (Deploy != \"azure\")" + "condition": "(server != \"suave\") || (deploy != \"azure\")" }, { "rename": { "Suaveweb.config": "web.config" } }, { "exclude": "**/SuaveAzure.fs", - "condition": "(Server != \"suave\") || (Deploy != \"azure\")" + "condition": "(server != \"suave\") || (deploy != \"azure\")" }, { "rename": { "SuaveAzure.fs": "Azure.fs" } }, { "exclude": "**/ServerGiraffe.fs", - "condition": "(Server != \"giraffe\")" + "condition": "(server != \"giraffe\")" }, { "rename": { "ServerGiraffe.fs": "Server.fs" } }, { "exclude": "**/ServerSaturn.fs", - "condition": "(Server != \"saturn\")" + "condition": "(server != \"saturn\")" }, { "rename": { "ServerSaturn.fs": "Server.fs" } }, { "exclude": "**/admin.css", - "condition": "(Fulma != \"admin\")" + "condition": "(fulma != \"admin\")" }, { "exclude": "**/hero.css", - "condition": "(Fulma != \"hero\")" + "condition": "(fulma != \"hero\")" }, { "exclude": "**/landing.css", - "condition": "(Fulma != \"landing\")" + "condition": "(fulma != \"landing\")" }, { "exclude": "**/login.css", - "condition": "(Fulma != \"login\")" + "condition": "(fulma != \"login\")" }, { "exclude": "Dockerfile", - "condition": "(Deploy != \"docker\")" + "condition": "(deploy != \"docker\")" }, { "exclude": "arm-template.json", - "condition": "(Deploy != \"azure\")" + "condition": "(deploy != \"azure\")" }, { "exclude": "yarn.lock", - "condition": "(NPM)" + "condition": "(npm)" } ] } From 33285c19dce3522883f87c4bbde5787159f08a8a Mon Sep 17 00:00:00 2001 From: callum vass Date: Tue, 15 May 2018 21:56:21 +0100 Subject: [PATCH 2/2] Updated template references in project files --- Content/build.fsx | 14 ++++++------ Content/paket.dependencies | 20 ++++++++--------- Content/src/Client/Client.fs | 32 ++++++++++++++-------------- Content/src/Client/paket.references | 4 ++-- Content/src/Client/public/index.html | 14 ++++++------ Content/src/Server/Server.fsproj | 6 +++--- Content/src/Server/ServerGiraffe.fs | 14 ++++++------ Content/src/Server/ServerSaturn.fs | 16 +++++++------- Content/src/Server/ServerSuave.fs | 18 ++++++++-------- Content/src/Server/paket.references | 14 ++++++------ Content/src/Shared/Shared.fs | 4 ++-- 11 files changed, 78 insertions(+), 78 deletions(-) diff --git a/Content/build.fsx b/Content/build.fsx index 3783e032..876fcdd0 100644 --- a/Content/build.fsx +++ b/Content/build.fsx @@ -1,5 +1,5 @@ #r @"packages/build/FAKE/tools/FakeLib.dll" -//#if (Deploy == "azure") +//#if (deploy == "azure") #r "netstandard" #I "packages/build/Microsoft.Rest.ClientRuntime.Azure/lib/net452" #load ".paket/load/netcoreapp2.1/Build/build.group.fsx" @@ -21,7 +21,7 @@ let platformTool tool winTool = match tryFindFileOnPath tool with Some t -> t | _ -> failwithf "%s not found" tool let nodeTool = platformTool "node" "node.exe" -//#if (NPM) +//#if (npm) let npmTool = platformTool "npm" "npm.cmd" //#else let yarnTool = platformTool "yarn" "yarn.cmd" @@ -49,7 +49,7 @@ Target "InstallDotNetCore" (fun _ -> Target "InstallClient" (fun _ -> printfn "Node version:" run nodeTool "--version" __SOURCE_DIRECTORY__ -//#if (NPM) +//#if (npm) printfn "Npm version:" run npmTool "--version" __SOURCE_DIRECTORY__ run npmTool "install" __SOURCE_DIRECTORY__ @@ -88,7 +88,7 @@ Target "Run" (fun () -> |> ignore ) -//#if (Deploy == "docker") +//#if (deploy == "docker") Target "Bundle" (fun _ -> let serverDir = deployDir "Server" let clientDir = deployDir "Client" @@ -113,7 +113,7 @@ Target "Docker" (fun _ -> ) //#endif -//#if (Deploy == "azure") +//#if (deploy == "azure") Target "Bundle" (fun () -> run dotnetCli (sprintf "publish %s -c release -o %s" serverPath deployDir) __SOURCE_DIRECTORY__ CopyDir (deployDir "public") (clientPath "public") allFiles @@ -178,10 +178,10 @@ Target "AppService" (fun _ -> ==> "InstallDotNetCore" ==> "InstallClient" ==> "Build" -//#if (Deploy == "docker") +//#if (deploy == "docker") ==> "Bundle" ==> "Docker" -//#elseif (Deploy == "azure") +//#elseif (deploy == "azure") ==> "Bundle" ==> "ArmTemplate" ==> "AppService" diff --git a/Content/paket.dependencies b/Content/paket.dependencies index 03ea27e1..16f9ef44 100644 --- a/Content/paket.dependencies +++ b/Content/paket.dependencies @@ -3,23 +3,23 @@ group Server source https://api.nuget.org/v3/index.json nuget FSharp.Core -//#if (Server == "suave") +//#if (server == "suave") nuget Suave -//#elseif (Server == "giraffe") +//#elseif (server == "giraffe") nuget Giraffe ~> 1 nuget Microsoft.AspNetCore nuget Microsoft.AspNetCore.StaticFiles -//#elseif (Server == "saturn") +//#elseif (server == "saturn") nuget Saturn //#endif -//#if (!Remoting && Server != "suave") +//#if (!remoting && server != "suave") nuget Fable.JsonConverter -//#elseif (Remoting && Server == "suave") +//#elseif (remoting && server == "suave") nuget Fable.Remoting.Suave ~> 2.6 -//#elseif (Remoting && Server != "suave") +//#elseif (remoting && server != "suave") nuget Fable.Remoting.Giraffe ~> 2.6 //#endif -//#if (Deploy == "azure") +//#if (deploy == "azure") nuget Microsoft.ApplicationInsights.AspNetCore ~> 2.2 nuget WindowsAzure.Storage //#endif @@ -34,10 +34,10 @@ group Client nuget Fable.Elmish.Debugger nuget Fable.Elmish.React nuget Fable.Elmish.HMR -//#if (Remoting) +//#if (remoting) nuget Fable.Remoting.Client ~> 2.4 //#endif -//#if (Fulma != "none") +//#if (fulma != "none") nuget Fulma //#endif @@ -48,7 +48,7 @@ group Build generate_load_scripts: true nuget FAKE -//#if (Deploy == "azure") +//#if (deploy == "azure") nuget Microsoft.Azure.Management.ResourceManager.Fluent 1.4.1 github CompositionalIT/fshelpers src/FsHelpers/ArmHelper/ArmHelper.fs //#endif diff --git a/Content/src/Client/Client.fs b/Content/src/Client/Client.fs index ec4c275b..54fad3aa 100644 --- a/Content/src/Client/Client.fs +++ b/Content/src/Client/Client.fs @@ -9,11 +9,11 @@ open Fable.PowerPack.Fetch open Shared -#if (Fulma != "none") +#if (fulma != "none") open Fulma #endif -#if (Fulma == "admin" || Fulma == "cover" || Fulma == "hero" || Fulma == "landing" || Fulma == "login") +#if (fulma == "admin" || fulma == "cover" || fulma == "hero" || fulma == "landing" || fulma == "login") open Fulma.FontAwesome #endif @@ -25,7 +25,7 @@ type Msg = | Init of Result -#if (Remoting) +#if (remoting) module Server = open Shared @@ -42,7 +42,7 @@ module Server = let init () : Model * Cmd = let model = None let cmd = -#if Remoting +#if remoting Cmd.ofAsync Server.api.getInitCounter () @@ -74,22 +74,22 @@ let safeComponents = let components = [ -#if (Server == "suave") +#if (server == "suave") "Suave", "http://suave.io" -#elseif (Server == "giraffe") +#elseif (server == "giraffe") "Giraffe", "https://github.com/giraffe-fsharp/Giraffe" -#elseif (Server == "saturn") +#elseif (server == "saturn") "Saturn", "https://saturnframework.github.io/docs/" #endif "Fable", "http://fable.io" "Elmish", "https://fable-elmish.github.io/" -#if (Fulma != "none") +#if (fulma != "none") "Fulma", "https://mangelmaxime.github.io/Fulma" #endif -#if (Fulma == "admin" || Fulma == "cover" || Fulma == "hero" || Fulma == "landing" || Fulma == "login") +#if (fulma == "admin" || fulma == "cover" || fulma == "hero" || fulma == "landing" || fulma == "login") "Bulma\u00A0Templates", "https://dansup.github.io/bulma-templates/" #endif -#if (Remoting) +#if (remoting) "Fable.Remoting", "https://zaid-ajaj.github.io/Fable.Remoting/" #endif ] @@ -106,7 +106,7 @@ let show = function | Some x -> string x | None -> "Loading..." -#if (Fulma == "none") +#if (fulma == "none") let view (model : Model) (dispatch : Msg -> unit) = div [] [ h1 [] [ str "SAFE Template" ] @@ -116,7 +116,7 @@ let view (model : Model) (dispatch : Msg -> unit) = div [] [ str (show model) ] button [ OnClick (fun _ -> dispatch Increment) ] [ str "+" ] safeComponents ] -#elseif (Fulma == "basic") +#elseif (fulma == "basic") let button txt onClick = Button.button [ Button.IsFullWidth @@ -141,7 +141,7 @@ let view (model : Model) (dispatch : Msg -> unit) = Footer.footer [ ] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ safeComponents ] ] ] -#elseif (Fulma == "admin") +#elseif (fulma == "admin") let navBrand = Navbar.navbar [ Navbar.Color IsWhite ] [ Container.container [ ] @@ -351,7 +351,7 @@ let view (model : Model) (dispatch : Msg -> unit) = hero info columns model dispatch ] ] ] ] -#elseif (Fulma == "cover") +#elseif (fulma == "cover") let navBrand = Navbar.Brand.div [ ] [ Navbar.Item.a @@ -434,7 +434,7 @@ let view (model : Model) (dispatch : Msg -> unit) = [ li [ ] [ a [ ] [ str "And this at the bottom" ] ] ] ] ] ] ] -#elseif (Fulma == "hero") +#elseif (fulma == "hero") let navBrand = Navbar.Brand.div [ ] [ Navbar.Item.a @@ -641,7 +641,7 @@ let view (model : Model) (dispatch : Msg -> unit) = footer [ ClassName "footer" ] [ footerContainer ] ] -#elseif (Fulma == "landing") +#elseif (fulma == "landing") let navBrand = Navbar.Brand.div [ ] [ Navbar.Item.a diff --git a/Content/src/Client/paket.references b/Content/src/Client/paket.references index 7c80ce85..3024bea4 100644 --- a/Content/src/Client/paket.references +++ b/Content/src/Client/paket.references @@ -5,9 +5,9 @@ group Client Fable.Elmish.HMR Fable.Core dotnet-fable -//#if (Fulma != "none") +//#if (fulma != "none") Fulma //#endif -//#if (Remoting) +//#if (remoting) Fable.Remoting.Client //#endif \ No newline at end of file diff --git a/Content/src/Client/public/index.html b/Content/src/Client/public/index.html index 667abebd..5ec999bc 100644 --- a/Content/src/Client/public/index.html +++ b/Content/src/Client/public/index.html @@ -3,24 +3,24 @@ SAFE Template - - - - - - - diff --git a/Content/src/Server/Server.fsproj b/Content/src/Server/Server.fsproj index 028c0bb8..6ba0a6a5 100644 --- a/Content/src/Server/Server.fsproj +++ b/Content/src/Server/Server.fsproj @@ -1,5 +1,5 @@  -#if (Deploy == "azure" && Server != "suave") +#if (deploy == "azure" && server != "suave") #else @@ -10,11 +10,11 @@ - #if (Deploy == "azure" && Server == "suave") + #if (deploy == "azure" && server == "suave") #endif - #if (Deploy == "azure" && Server == "suave") + #if (deploy == "azure" && server == "suave") PreserveNewest diff --git a/Content/src/Server/ServerGiraffe.fs b/Content/src/Server/ServerGiraffe.fs index 2bdd3d3c..9b1810f1 100644 --- a/Content/src/Server/ServerGiraffe.fs +++ b/Content/src/Server/ServerGiraffe.fs @@ -10,17 +10,17 @@ open Microsoft.Extensions.DependencyInjection open Giraffe open Shared -#if (Remoting) +#if (remoting) open Fable.Remoting.Server open Fable.Remoting.Giraffe #else open Giraffe.Serialization #endif -#if (Deploy == "azure") +#if (deploy == "azure") open Microsoft.WindowsAzure.Storage #endif -//#if (Deploy == "azure") +//#if (deploy == "azure") let tryGetEnv = System.Environment.GetEnvironmentVariable >> function null | "" -> None | x -> Some x let publicPath = tryGetEnv "public_path" |> Option.defaultValue "../Client/public" |> Path.GetFullPath let storageAccount = tryGetEnv "STORAGE_CONNECTIONSTRING" |> Option.defaultValue "UseDevelopmentStorage=true" |> CloudStorageAccount.Parse @@ -32,8 +32,8 @@ let port = 8085us let getInitCounter () : Task = task { return 42 } let webApp : HttpHandler = -#if (Remoting) - let counterProcotol = +#if (remoting) + let counterProcotol = { getInitCounter = getInitCounter >> Async.AwaitTask } // creates a HttpHandler for the given implementation remoting counterProcotol { @@ -55,12 +55,12 @@ let configureApp (app : IApplicationBuilder) = let configureServices (services : IServiceCollection) = services.AddGiraffe() |> ignore - #if (!Remoting) + #if (!remoting) let fableJsonSettings = Newtonsoft.Json.JsonSerializerSettings() fableJsonSettings.Converters.Add(Fable.JsonConverter()) services.AddSingleton(NewtonsoftJsonSerializer fableJsonSettings) |> ignore #endif - #if (Deploy == "azure") + #if (deploy == "azure") tryGetEnv "APPINSIGHTS_INSTRUMENTATIONKEY" |> Option.iter (services.AddApplicationInsightsTelemetry >> ignore) #endif diff --git a/Content/src/Server/ServerSaturn.fs b/Content/src/Server/ServerSaturn.fs index 626b9d94..e5d5c34a 100644 --- a/Content/src/Server/ServerSaturn.fs +++ b/Content/src/Server/ServerSaturn.fs @@ -7,17 +7,17 @@ open Giraffe open Saturn open Shared -#if (Remoting) +#if (remoting) open Fable.Remoting.Server open Fable.Remoting.Giraffe #else open Giraffe.Serialization #endif -#if (Deploy == "azure") +#if (deploy == "azure") open Microsoft.WindowsAzure.Storage #endif -//#if (Deploy == "azure") +//#if (deploy == "azure") let tryGetEnv = System.Environment.GetEnvironmentVariable >> function null | "" -> None | x -> Some x let publicPath = tryGetEnv "public_path" |> Option.defaultValue "../Client/public" |> Path.GetFullPath let storageAccount = tryGetEnv "STORAGE_CONNECTIONSTRING" |> Option.defaultValue "UseDevelopmentStorage=true" |> CloudStorageAccount.Parse @@ -28,7 +28,7 @@ let port = 8085us let getInitCounter () : Task = task { return 42 } -#if (Remoting) +#if (remoting) let webApp = let server = { getInitCounter = getInitCounter >> Async.AwaitTask } @@ -45,14 +45,14 @@ let webApp = scope { } #endif -#if (!Remoting) +#if (!remoting) let configureSerialization (services:IServiceCollection) = let fableJsonSettings = Newtonsoft.Json.JsonSerializerSettings() fableJsonSettings.Converters.Add(Fable.JsonConverter()) services.AddSingleton(NewtonsoftJsonSerializer fableJsonSettings) #endif -#if (Deploy == "azure") +#if (deploy == "azure") let configureAzure (services:IServiceCollection) = tryGetEnv "APPINSIGHTS_INSTRUMENTATIONKEY" |> Option.map services.AddApplicationInsightsTelemetry @@ -68,10 +68,10 @@ let app = application { app_config configureApp memory_cache use_static publicPath - #if (!Remoting) + #if (!remoting) service_config configureSerialization #endif - #if (Deploy == "azure") + #if (deploy == "azure") service_config configureAzure #endif use_gzip diff --git a/Content/src/Server/ServerSuave.fs b/Content/src/Server/ServerSuave.fs index 74448c28..f9a45f5a 100644 --- a/Content/src/Server/ServerSuave.fs +++ b/Content/src/Server/ServerSuave.fs @@ -6,15 +6,15 @@ open Suave.Operators open Shared -#if (Remoting) +#if (remoting) open Fable.Remoting.Server open Fable.Remoting.Suave #endif -#if (Deploy == "azure") +#if (deploy == "azure") open Microsoft.WindowsAzure.Storage #endif -//#if (Deploy == "azure") +//#if (deploy == "azure") let publicPath = Azure.tryGetEnv "public_path" |> Option.defaultValue "../Client/public" |> Path.GetFullPath let port = Azure.tryGetEnv "HTTP_PLATFORM_PORT" |> Option.map System.UInt16.Parse |> Option.defaultValue 8085us let storageAccount = Azure.tryGetEnv "STORAGE_CONNECTIONSTRING" |> Option.defaultValue "UseDevelopmentStorage=true" |> CloudStorageAccount.Parse @@ -24,20 +24,20 @@ let port = 8085us //#endif let config = - { defaultConfig with + { defaultConfig with homeFolder = Some publicPath bindings = [ HttpBinding.create HTTP (IPAddress.Parse "0.0.0.0") port ] } let getInitCounter () : Async = async { return 42 } -let webApi : WebPart = -#if (Remoting) - let counterProcotol = +let webApi : WebPart = +#if (remoting) + let counterProcotol = { getInitCounter = getInitCounter } // Create a WebPart for the given implementation of the protocol remoting counterProcotol { // define how routes are mapped - use_route_builder Route.builder + use_route_builder Route.builder } #else Filters.path "/api/init" >=> @@ -54,7 +54,7 @@ let webApp = Filters.path "/" >=> Files.browseFileHome "index.html" Files.browseHome RequestErrors.NOT_FOUND "Not found!" -#if (Deploy == "azure") +#if (deploy == "azure") ] |> Azure.AI.withAppInsights Azure.AI.buildApiOperationName Azure.AppServices.addTraceListeners() diff --git a/Content/src/Server/paket.references b/Content/src/Server/paket.references index b232077d..7fcbfeff 100644 --- a/Content/src/Server/paket.references +++ b/Content/src/Server/paket.references @@ -1,23 +1,23 @@ group Server FSharp.Core -//#if (Server == "suave") +//#if (server == "suave") Suave -//#elseif (Server == "giraffe") +//#elseif (server == "giraffe") Giraffe Microsoft.AspNetCore Microsoft.AspNetCore.StaticFiles -//#elseif (Server == "saturn") +//#elseif (server == "saturn") Saturn //#endif -//#if (Deploy == "azure") +//#if (deploy == "azure") Microsoft.ApplicationInsights.AspNetCore WindowsAzure.Storage //#endif -//#if (!Remoting && Server != "suave") +//#if (!remoting && server != "suave") Fable.JsonConverter -//#elseif (Remoting && Server == "suave") +//#elseif (remoting && server == "suave") Fable.Remoting.Suave -//#elseif (Remoting) +//#elseif (remoting) Fable.Remoting.Giraffe //#endif Microsoft.DotNet.Watcher.Tools \ No newline at end of file diff --git a/Content/src/Shared/Shared.fs b/Content/src/Shared/Shared.fs index fe9d6e56..9c50ae46 100644 --- a/Content/src/Shared/Shared.fs +++ b/Content/src/Shared/Shared.fs @@ -2,10 +2,10 @@ namespace Shared type Counter = int -#if (Remoting) +#if (remoting) module Route = /// Defines how routes are generated on server and mapped from client - let builder typeName methodName = + let builder typeName methodName = sprintf "/api/%s/%s" typeName methodName /// A type that specifies the communication protocol for client and server