From 99c84cd9ee7a7664500395e4c4d2da137921cf10 Mon Sep 17 00:00:00 2001 From: Isaac Abraham Date: Sat, 30 May 2020 19:38:25 +0200 Subject: [PATCH] Add Azure support. Template naming applied throughout. --- Content/.template.config/template.json | 34 +++++++----------- Content/README-minimal.md | 4 +-- Content/{SAFE.Template.sln => SAFE.App.sln} | 6 ++-- Content/build.fsx | 22 ++++++++++-- Content/paket.dependencies | 3 +- Content/paket.lock | 5 ++- .../src/{Client => SAFE.App.Client}/Client.fs | 11 +++--- .../SAFE.App.Client.fsproj} | 4 +-- .../{Client => SAFE.App.Client}/index.html | 0 .../package-lock.default.json | 0 .../package-lock.minimal.json | 0 .../package.default.json | 0 .../package.minimal.json | 0 .../paket.references | 0 .../public/favicon.png | Bin .../webpack.default.config.js | 2 +- .../webpack.minimal.config.js | 2 +- .../SAFE.App.Server.fsproj} | 4 +-- .../src/{Server => SAFE.App.Server}/Server.fs | 4 ++- .../paket.references | 0 .../SAFE.App.Shared.fsproj} | 0 .../src/{Shared => SAFE.App.Shared}/Shared.fs | 2 +- SAFE.Template.proj | 6 ++-- build.fsx | 4 +-- 24 files changed, 64 insertions(+), 49 deletions(-) rename Content/{SAFE.Template.sln => SAFE.App.sln} (80%) rename Content/src/{Client => SAFE.App.Client}/Client.fs (96%) rename Content/src/{Client/Client.fsproj => SAFE.App.Client/SAFE.App.Client.fsproj} (93%) rename Content/src/{Client => SAFE.App.Client}/index.html (100%) rename Content/src/{Client => SAFE.App.Client}/package-lock.default.json (100%) rename Content/src/{Client => SAFE.App.Client}/package-lock.minimal.json (100%) rename Content/src/{Client => SAFE.App.Client}/package.default.json (100%) rename Content/src/{Client => SAFE.App.Client}/package.minimal.json (100%) rename Content/src/{Client => SAFE.App.Client}/paket.references (100%) rename Content/src/{Client => SAFE.App.Client}/public/favicon.png (100%) rename Content/src/{Client => SAFE.App.Client}/webpack.default.config.js (99%) rename Content/src/{Client => SAFE.App.Client}/webpack.minimal.config.js (97%) rename Content/src/{Server/Server.fsproj => SAFE.App.Server/SAFE.App.Server.fsproj} (89%) rename Content/src/{Server => SAFE.App.Server}/Server.fs (94%) rename Content/src/{Server => SAFE.App.Server}/paket.references (100%) rename Content/src/{Shared/Shared.fsproj => SAFE.App.Shared/SAFE.App.Shared.fsproj} (100%) rename Content/src/{Shared => SAFE.App.Shared}/Shared.fs (91%) diff --git a/Content/.template.config/template.json b/Content/.template.config/template.json index 6cc9f795..cd1b55e1 100644 --- a/Content/.template.config/template.json +++ b/Content/.template.config/template.json @@ -15,16 +15,8 @@ }, "identity": "SAFE.Template", "shortName": "SAFE", - "sourceName": "SAFE.Template", + "sourceName": "SAFE.App", "symbols": { - "createdate": { - "type": "generated", - "generator": "now", - "parameters": { - "format": "yyyy-MM-dd" - }, - "replaces": "1970-01-01" - }, "minimal": { "type": "parameter", "dataType": "bool", @@ -49,30 +41,30 @@ "RELEASE_NOTES.md", "**/paket.*", "*.fsx", - "src/Client/package.default.json", - "src/Client/package-lock.default.json", - "src/Client/webpack.default.config.js", + "src/SAFE.App.Client/package.default.json", + "src/SAFE.App.Client/package-lock.default.json", + "src/SAFE.App.Client/webpack.default.config.js", "README.md" ], "condition": "(minimal)" }, { "exclude": [ - "src/Client/package.minimal.json", - "src/Client/package-lock.minimal.json", - "src/Client/webpack.minimal.config.js", + "src/SAFE.App.Client/package.minimal.json", + "src/SAFE.App.Client/package-lock.minimal.json", + "src/SAFE.App.Client/webpack.minimal.config.js", "README-minimal.md" ], "condition": "(!minimal)" }, { "rename": { - "src/Client/webpack.default.config.js": "src/Client/webpack.config.js", - "src/Client/webpack.minimal.config.js": "src/Client/webpack.config.js", - "src/Client/package.minimal.json": "src/Client/package.json", - "src/Client/package.default.json": "src/Client/package.json", - "src/Client/package-lock.minimal.json": "src/Client/package-lock.json", - "src/Client/package-lock.default.json": "src/Client/package-lock.json", + "src/SAFE.App.Client/webpack.default.config.js": "src/SAFE.App.Client/webpack.config.js", + "src/SAFE.App.Client/webpack.minimal.config.js": "src/SAFE.App.Client/webpack.config.js", + "src/SAFE.App.Client/package.minimal.json": "src/SAFE.App.Client/package.json", + "src/SAFE.App.Client/package.default.json": "src/SAFE.App.Client/package.json", + "src/SAFE.App.Client/package-lock.minimal.json": "src/SAFE.App.Client/package-lock.json", + "src/SAFE.App.Client/package-lock.default.json": "src/SAFE.App.Client/package-lock.json", "README-minimal.md": "README.md" } } diff --git a/Content/README-minimal.md b/Content/README-minimal.md index cb5cbbdb..91f3d27a 100644 --- a/Content/README-minimal.md +++ b/Content/README-minimal.md @@ -11,13 +11,13 @@ You'll need to install the following pre-requisites in order to build SAFE appli ## Starting the application Start the server: ```bash -cd src\server +cd src\SAFE.App.server\ dotnet run ``` Start the client: ```bash -cd src\client +cd src\SAFE.App.Client\ npm install npm run start ``` diff --git a/Content/SAFE.Template.sln b/Content/SAFE.App.sln similarity index 80% rename from Content/SAFE.Template.sln rename to Content/SAFE.App.sln index 98ac70ba..8ec6dbc0 100644 --- a/Content/SAFE.Template.sln +++ b/Content/SAFE.App.sln @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27004.2005 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Client", "src\Client\Client.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SAFE.App.Client", "src\SAFE.App.Client\SAFE.App.Client.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Server", "src\Server\Server.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SAFE.App.Server", "src\SAFE.App.Server\SAFE.App.Server.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Shared", "src\Shared\Shared.fsproj", "{28F090FB-E75F-4BE9-9E09-A70B1DA02C88}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SAFE.App.Shared", "src\SAFE.App.Shared\SAFE.App.Shared.fsproj", "{28F090FB-E75F-4BE9-9E09-A70B1DA02C88}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{08CCFCF6-2248-43ED-A6EF-E972A2DA0E6A}" ProjectSection(SolutionItems) = preProject diff --git a/Content/build.fsx b/Content/build.fsx index c2724bf7..08624254 100644 --- a/Content/build.fsx +++ b/Content/build.fsx @@ -5,11 +5,13 @@ open Fake.Core open Fake.DotNet open Fake.IO +open Farmer +open Farmer.Builders Target.initEnvironment () -let serverPath = Path.getFullName "./src/Server" -let clientPath = Path.getFullName "./src/Client" +let serverPath = Path.getFullName "./src/SAFE.App.Server" +let clientPath = Path.getFullName "./src/SAFE.App.Client" let deployDir = Path.getFullName "./deploy" let npm args workingDir = @@ -48,6 +50,21 @@ Target.create "Bundle" (fun _ -> npm "run build" clientPath ) +Target.create "Azure" (fun _ -> + let web = webApp { + name "SAFE.App" + zip_deploy "deploy" + } + let deployment = arm { + location Location.WestEurope + add_resource web + } + + deployment + |> Deploy.execute "SAFE.App" Deploy.NoParameters + |> ignore +) + Target.create "Run" (fun _ -> [ async { dotnet "watch run" serverPath } async { npm "run start" clientPath } ] @@ -61,6 +78,7 @@ open Fake.Core.TargetOperators "Clean" ==> "InstallClient" ==> "Bundle" + ==> "Azure" "Clean" ==> "InstallClient" diff --git a/Content/paket.dependencies b/Content/paket.dependencies index d6163ee0..139fd8ca 100644 --- a/Content/paket.dependencies +++ b/Content/paket.dependencies @@ -24,4 +24,5 @@ group Build nuget Fake.Core.ReleaseNotes nuget Fake.Core.Target nuget Fake.DotNet.Cli - nuget Fake.IO.FileSystem \ No newline at end of file + nuget Fake.IO.FileSystem + nuget Farmer diff --git a/Content/paket.lock b/Content/paket.lock index e829838f..badb4575 100644 --- a/Content/paket.lock +++ b/Content/paket.lock @@ -85,7 +85,7 @@ NUGET FSharp.Control.Websockets (0.2.2) FSharp.Core (>= 4.3.4) Microsoft.IO.RecyclableMemoryStream (>= 1.2.2) - FSharp.Core (4.7) + FSharp.Core (4.7.2) Fulma (2.7) Fable.Core (>= 3.0) Fable.React (>= 5.1) @@ -780,6 +780,9 @@ NUGET Fake.Core.Trace (>= 5.19.1) FSharp.Core (>= 4.7) System.Net.Http (>= 4.3.4) + Farmer (0.14) + FSharp.Core (>= 4.7.1) + Newtonsoft.Json (>= 12.0.2) FParsec (1.1.1) FSharp.Core (>= 4.3.4) FSharp.Control.Reactive (4.2) diff --git a/Content/src/Client/Client.fs b/Content/src/SAFE.App.Client/Client.fs similarity index 96% rename from Content/src/Client/Client.fs rename to Content/src/SAFE.App.Client/Client.fs index 18026c05..7776eb6e 100644 --- a/Content/src/Client/Client.fs +++ b/Content/src/SAFE.App.Client/Client.fs @@ -1,10 +1,10 @@ -module Client +module SAFE.App.Client open Elmish open Elmish.React open Fable.React open Fable.React.Props -open Shared +open SAFE.App.Shared (*#if (minimal) open Thoth.Fetch #else*) @@ -60,7 +60,7 @@ let show = let view model dispatch = div [ Style [ TextAlign TextAlignOptions.Center; Padding 40 ] ] [ img [ Src "favicon.png" ] - h1 [] [ str "SAFE Template" ] + h1 [] [ str "SAFE.App" ] h2 [] [ str (show model) ] button [ Style [ Margin 5; Padding 10 ]; OnClick(fun _ -> dispatch Decrement) ] [ str "-" @@ -85,8 +85,7 @@ let safeComponents = ] footer [ ] [ - str "Version " - str " powered by: " + str "Powered by: " components ] @@ -151,7 +150,7 @@ let view (model : Model) (dispatch : Msg -> unit) = Column.Width (Screen.All, Column.Is6) Column.Offset (Screen.All, Column.Is3) ] [ - Heading.p [ ] [ str "SAFE Template" ] + Heading.p [ ] [ str "SAFE.App" ] Heading.p [ Heading.IsSubtitle ] [ safeComponents ] containerBox model dispatch ] diff --git a/Content/src/Client/Client.fsproj b/Content/src/SAFE.App.Client/SAFE.App.Client.fsproj similarity index 93% rename from Content/src/Client/Client.fsproj rename to Content/src/SAFE.App.Client/SAFE.App.Client.fsproj index 6903c1f6..eac22de7 100644 --- a/Content/src/Client/Client.fsproj +++ b/Content/src/SAFE.App.Client/SAFE.App.Client.fsproj @@ -16,7 +16,7 @@ - + - + \ No newline at end of file diff --git a/Content/src/Client/index.html b/Content/src/SAFE.App.Client/index.html similarity index 100% rename from Content/src/Client/index.html rename to Content/src/SAFE.App.Client/index.html diff --git a/Content/src/Client/package-lock.default.json b/Content/src/SAFE.App.Client/package-lock.default.json similarity index 100% rename from Content/src/Client/package-lock.default.json rename to Content/src/SAFE.App.Client/package-lock.default.json diff --git a/Content/src/Client/package-lock.minimal.json b/Content/src/SAFE.App.Client/package-lock.minimal.json similarity index 100% rename from Content/src/Client/package-lock.minimal.json rename to Content/src/SAFE.App.Client/package-lock.minimal.json diff --git a/Content/src/Client/package.default.json b/Content/src/SAFE.App.Client/package.default.json similarity index 100% rename from Content/src/Client/package.default.json rename to Content/src/SAFE.App.Client/package.default.json diff --git a/Content/src/Client/package.minimal.json b/Content/src/SAFE.App.Client/package.minimal.json similarity index 100% rename from Content/src/Client/package.minimal.json rename to Content/src/SAFE.App.Client/package.minimal.json diff --git a/Content/src/Client/paket.references b/Content/src/SAFE.App.Client/paket.references similarity index 100% rename from Content/src/Client/paket.references rename to Content/src/SAFE.App.Client/paket.references diff --git a/Content/src/Client/public/favicon.png b/Content/src/SAFE.App.Client/public/favicon.png similarity index 100% rename from Content/src/Client/public/favicon.png rename to Content/src/SAFE.App.Client/public/favicon.png diff --git a/Content/src/Client/webpack.default.config.js b/Content/src/SAFE.App.Client/webpack.default.config.js similarity index 99% rename from Content/src/Client/webpack.default.config.js rename to Content/src/SAFE.App.Client/webpack.default.config.js index c510f625..4b59d8d3 100644 --- a/Content/src/Client/webpack.default.config.js +++ b/Content/src/SAFE.App.Client/webpack.default.config.js @@ -15,7 +15,7 @@ var CONFIG = { // The tags to include the generated JS and CSS will be automatically injected in the HTML template // See https://github.com/jantimon/html-webpack-plugin indexHtmlTemplate: './index.html', - fsharpEntry: './Client.fsproj', + fsharpEntry: './SAFE.App.Client.fsproj', cssEntry: './style.scss', outputDir: './../../deploy/public', assetsDir: './public', diff --git a/Content/src/Client/webpack.minimal.config.js b/Content/src/SAFE.App.Client/webpack.minimal.config.js similarity index 97% rename from Content/src/Client/webpack.minimal.config.js rename to Content/src/SAFE.App.Client/webpack.minimal.config.js index 5c02afec..00f75457 100644 --- a/Content/src/Client/webpack.minimal.config.js +++ b/Content/src/SAFE.App.Client/webpack.minimal.config.js @@ -53,7 +53,7 @@ var isProduction = !process.argv.find(v => v.indexOf('webpack-dev-server') !== - console.log('Bundling for ' + (isProduction ? 'production' : 'development') + '...'); module.exports = { - entry: { app: resolve('./Client.fsproj') }, + entry: { app: resolve('./SAFE.App.Client.fsproj') }, output: { path: resolve('./../../deploy/public') }, resolve: { symlinks: false }, // See https://github.com/fable-compiler/Fable/issues/1490 mode: isProduction ? 'production' : 'development', diff --git a/Content/src/Server/Server.fsproj b/Content/src/SAFE.App.Server/SAFE.App.Server.fsproj similarity index 89% rename from Content/src/Server/Server.fsproj rename to Content/src/SAFE.App.Server/SAFE.App.Server.fsproj index d4b11b75..95834673 100644 --- a/Content/src/Server/Server.fsproj +++ b/Content/src/SAFE.App.Server/SAFE.App.Server.fsproj @@ -12,7 +12,7 @@ - + - + \ No newline at end of file diff --git a/Content/src/Server/Server.fs b/Content/src/SAFE.App.Server/Server.fs similarity index 94% rename from Content/src/Server/Server.fs rename to Content/src/SAFE.App.Server/Server.fs index 70ac2750..b36a2745 100644 --- a/Content/src/Server/Server.fs +++ b/Content/src/SAFE.App.Server/Server.fs @@ -1,3 +1,5 @@ +module SAFE.App.Server + (*#if (minimal) open FSharp.Control.Tasks.V2 open Giraffe @@ -6,7 +8,7 @@ open Fable.Remoting.Server open Fable.Remoting.Giraffe //#endif open Saturn -open Shared +open SAFE.App.Shared (*#if (minimal) let webApp = diff --git a/Content/src/Server/paket.references b/Content/src/SAFE.App.Server/paket.references similarity index 100% rename from Content/src/Server/paket.references rename to Content/src/SAFE.App.Server/paket.references diff --git a/Content/src/Shared/Shared.fsproj b/Content/src/SAFE.App.Shared/SAFE.App.Shared.fsproj similarity index 100% rename from Content/src/Shared/Shared.fsproj rename to Content/src/SAFE.App.Shared/SAFE.App.Shared.fsproj diff --git a/Content/src/Shared/Shared.fs b/Content/src/SAFE.App.Shared/Shared.fs similarity index 91% rename from Content/src/Shared/Shared.fs rename to Content/src/SAFE.App.Shared/Shared.fs index 511ab511..690f716c 100644 --- a/Content/src/Shared/Shared.fs +++ b/Content/src/SAFE.App.Shared/Shared.fs @@ -1,4 +1,4 @@ -namespace Shared +namespace SAFE.App.Shared type Counter = { Value : int } //#if (!minimal) diff --git a/SAFE.Template.proj b/SAFE.Template.proj index 352e2494..caf0ee76 100644 --- a/SAFE.Template.proj +++ b/SAFE.Template.proj @@ -20,9 +20,9 @@ Content/src/**/obj/**/*; Content/src/**/bin/**/*; Content/packages/**/*; Content/paket-files/**/*; -Content/src/Client/.fable/**/*; -Content/src/Client/node_modules/**/*; -Content/src/Client/deploy/**/*; +Content/src/SAFE.App.Client/.fable/**/*; +Content/src/SAFE.App.Client/node_modules/**/*; +Content/src/SAFE.App.Client/deploy/**/*; diff --git a/build.fsx b/build.fsx index de6f104c..477d975b 100644 --- a/build.fsx +++ b/build.fsx @@ -32,7 +32,7 @@ Target.create "Clean" (fun _ -> Target.create "BuildWebPackConfig" (fun _ -> let srcDir = "paket-files/fable-compiler/webpack-config-template/webpack.config.js" - let destDir = "Content/src/Client/webpack.config.js" + let destDir = "Content/src/SAFE.App.Client/webpack.config.js" Shell.copyFile destDir srcDir let devServerProxy = @@ -54,7 +54,7 @@ Target.create "BuildWebPackConfig" (fun _ -> let replacements = [ "indexHtmlTemplate", quote "./index.html" - "fsharpEntry", quote "./Client.fsproj" + "fsharpEntry", quote "./SAFE.App.Client.fsproj" "cssEntry", quote "./style.scss" "devServerProxy", devServerProxy ]