Skip to content

Commit

Permalink
Add Azure support. Template naming applied throughout.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacabraham committed May 30, 2020
1 parent 6ecb3cd commit 99c84cd
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 49 deletions.
34 changes: 13 additions & 21 deletions Content/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
Expand Down
4 changes: 2 additions & 2 deletions Content/README-minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
6 changes: 3 additions & 3 deletions Content/SAFE.Template.sln → Content/SAFE.App.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions Content/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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 } ]
Expand All @@ -61,6 +78,7 @@ open Fake.Core.TargetOperators
"Clean"
==> "InstallClient"
==> "Bundle"
==> "Azure"

"Clean"
==> "InstallClient"
Expand Down
3 changes: 2 additions & 1 deletion Content/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ group Build
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.IO.FileSystem
nuget Farmer
5 changes: 4 additions & 1 deletion Content/paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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*)
Expand Down Expand Up @@ -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 "-"
Expand All @@ -85,8 +85,7 @@ let safeComponents =
]

footer [ ] [
str "Version "
str " powered by: "
str "Powered by: "
components
]

Expand Down Expand Up @@ -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
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Compile Include="Client.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.fsproj" />
<ProjectReference Include="..\SAFE.App.Shared\SAFE.App.Shared.fsproj" />
</ItemGroup>
<!--#if (minimal)
<ItemGroup>
Expand All @@ -29,6 +29,6 @@
<PackageReference Include="Thoth.Fetch" Version="2.0.0" />
</ItemGroup>
#else-->
<!--#endif-->
<Import Project="..\..\.paket\Paket.Restore.targets" />
<!--#endif-->
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<Compile Include="Server.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.fsproj" />
<ProjectReference Include="..\SAFE.App.Shared\SAFE.App.Shared.fsproj" />
</ItemGroup>
<!--#if (minimal)
<ItemGroup>
<PackageReference Include="Saturn" Version="0.12.1" />
<PackageReference Include="Thoth.Json.Giraffe" Version="4.0.0" />
</ItemGroup>
#else-->
<!--#endif-->
<Import Project="..\..\.paket\Paket.Restore.targets" />
<!--#endif-->
</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module SAFE.App.Server

(*#if (minimal)
open FSharp.Control.Tasks.V2
open Giraffe
Expand All @@ -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 =
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared
namespace SAFE.App.Shared

type Counter = { Value : int }
//#if (!minimal)
Expand Down
6 changes: 3 additions & 3 deletions SAFE.Template.proj
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*;
</ExcludeFromPackage>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
]
Expand Down

0 comments on commit 99c84cd

Please sign in to comment.